1# Ensure buildinfo is populated on test binaries even if they 2# are not tests for package main. See issue #33976. 3 4[short] skip 'invokes go test' 5 6go mod init foo 7go test -v 8stdout '(devel)' 9 10-- foo_test.go -- 11package foo_test 12 13import ( 14 "runtime/debug" 15 "testing" 16) 17 18func TestBuildInfo(t *testing.T) { 19 info, ok := debug.ReadBuildInfo() 20 if !ok { 21 t.Fatal("no debug info") 22 } 23 t.Log(info.Main.Version) 24}