Hi
I’m trying to get “version” from debug.BuildInfo:
package main
import (
"fmt"
"runtime/debug"
)
func main() {
bi, ok := debug.ReadBuildInfo()
if !ok {
fmt.Println("not ok")
return
}
fmt.Printf("Version: %s\n", bi.Main.Version)
}
Output:
Version: (devel)
I have tried with versions:
go1.17.5
go1.18beta1
I got the same result, with both versions.
Does it exist any way for go compiler to update Main.Version to git tag/go.mod-version (without using -ldflags="-X path.to.variable=value")?