// TestGoVersion tests that the Go version specified in go.mod matches ./tool/go version.
funcTestGoVersion(t*testing.T){
// We could special-case ./tool/go path for Windows, but really there is no
// need to run it there.
ifruntime.GOOS=="windows"{
t.Skip("Skipping test on Windows")
}
goModVersion:=mustGetGoModVersion(t,true)
goToolCmd:=exec.Command("./tool/go","version")
goToolOutput,err:=goToolCmd.Output()
iferr!=nil{
t.Fatalf("Failed to get ./tool/go version: %v",err)
}
// Version info will approximately look like 'go version go1.24.4 linux/amd64'.
parts:=strings.Fields(string(goToolOutput))
iflen(parts)<4{
t.Fatalf("Unexpected ./tool/go version output format: %s",goToolOutput)
}
goToolVersion:=strings.TrimPrefix(parts[2],"go")
ifgoModVersion!=goToolVersion{
t.Errorf("Go version in go.mod (%q) does not match the version of ./tool/go (%q).\nEnsure that the go.mod refers to the same Go version as ./go.toolchain.rev.",