From 408b565fd96064876b1107b0dfc34d054a5c170b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 18 Feb 2020 13:47:57 +0100 Subject: [PATCH] Allow setting version via ldflags again --- command/root.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/command/root.go b/command/root.go index 21b26778b..4f9d5ba09 100644 --- a/command/root.go +++ b/command/root.go @@ -17,12 +17,7 @@ import ( ) // Version is dynamically set by the toolchain or overriden by the Makefile. -var Version = func(info *debug.BuildInfo, ok bool) string { - if !ok { - return "(devel)" - } - return info.Main.Version -}(debug.ReadBuildInfo()) +var Version = "DEV" // BuildDate is dynamically set at build time in the Makefile. var BuildDate = "" // YYYY-MM-DD @@ -30,7 +25,12 @@ var BuildDate = "" // YYYY-MM-DD var versionOutput = "" func init() { - Version = strings.TrimPrefix(info.Main.Version, "v") + if Version == "DEV" { + if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" { + Version = info.Main.Version + } + } + Version = strings.TrimPrefix(Version, "v") if BuildDate == "" { RootCmd.Version = Version } else {