diff --git a/internal/version/version.go b/internal/version/version.go index 30d8a5a902..f3b9bb31b5 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -5,6 +5,7 @@ package version import ( + "runtime/debug" "strconv" "time" ) @@ -20,6 +21,17 @@ var ( Tag string ) +// Set Tag to version stored in modinfo if it is not available from the builder. +func init() { + if Tag != "" { + return + } + info, ok := debug.ReadBuildInfo() + if ok && info.Main.Version != "(devel)" { + Tag = info.Main.Version + } +} + // BuildTimeFormatted method returns the build time preserving the RFC3339 format. func BuildTimeFormatted() string { if BuildTime == "unknown" {