I have tried using go build -buildvcs=true but debug.ReadBuildInfo().Main.Version is still empty.
On top of that, this issue can be reproduced in a git repo with the following test:
func TestReadBuildInfo(t *testing.T) {
bi, ok := debug.ReadBuildInfo()
require.True(t, ok)
require.NotEmpty(t, bi.Main.Version)
}
go test -buildvcs=true ./...
Is there something I am missing here? How do I get this working?