From a332421dc23afc303fafaf87728043693389e65f Mon Sep 17 00:00:00 2001 From: harakeishi Date: Sat, 26 Feb 2022 11:06:35 +0900 Subject: [PATCH] fix --- .goreleaser.yaml | 2 +- cmd/root.go | 11 +++++------ main.go | 6 +----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c33aec6..aa9a4db 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -12,7 +12,7 @@ builds: - windows - darwin ldflags: - - -s -w -X "main.version={{.Env.Version}}" + - -s -w -X github.com/harakeishi/whris/cmd.ver={{.Version}} archives: - replacements: darwin: Darwin diff --git a/cmd/root.go b/cmd/root.go index 8789f24..7fa6335 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/cobra" ) -var Ver = "dev" +var ver = "dev" var rootCmd = &cobra.Command{ Use: "whris", Short: "`whris` is Displays management information for IPs associated with the domain.", @@ -22,12 +22,12 @@ var rootCmd = &cobra.Command{ os.Exit(1) } if version { - if strings.Contains(Ver, "dev") { - fmt.Println(Ver) + if !strings.Contains(ver, "dev") { + fmt.Println(ver) return nil } if buildInfo, ok := debug.ReadBuildInfo(); ok { - fmt.Println(buildInfo.Main.Version) + fmt.Printf("%+v\n", buildInfo.Main) return nil } fmt.Println("unknown") @@ -47,8 +47,7 @@ var rootCmd = &cobra.Command{ }, } -func Execute(ver string) { - Ver = ver +func Execute() { err := rootCmd.Execute() if err != nil { os.Exit(1) diff --git a/main.go b/main.go index ee80900..e1e19b0 100644 --- a/main.go +++ b/main.go @@ -8,10 +8,6 @@ import ( "github.com/harakeishi/whris/cmd" ) -var ( - version = "dev" -) - func main() { - cmd.Execute(version) + cmd.Execute() }