Skip to content

Commit 408b565

Browse files
committed
Allow setting version via ldflags again
1 parent de6e99a commit 408b565

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

command/root.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ import (
1717
)
1818

1919
// Version is dynamically set by the toolchain or overriden by the Makefile.
20-
var Version = func(info *debug.BuildInfo, ok bool) string {
21-
if !ok {
22-
return "(devel)"
23-
}
24-
return info.Main.Version
25-
}(debug.ReadBuildInfo())
20+
var Version = "DEV"
2621

2722
// BuildDate is dynamically set at build time in the Makefile.
2823
var BuildDate = "" // YYYY-MM-DD
2924

3025
var versionOutput = ""
3126

3227
func init() {
33-
Version = strings.TrimPrefix(info.Main.Version, "v")
28+
if Version == "DEV" {
29+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" {
30+
Version = info.Main.Version
31+
}
32+
}
33+
Version = strings.TrimPrefix(Version, "v")
3434
if BuildDate == "" {
3535
RootCmd.Version = Version
3636
} else {

0 commit comments

Comments
 (0)