Go version
go version go1.22.0 linux/amd64
Output of go env in your module/workspace:
What did you do?
main.go:
//go:build go1.21
package main
func main() {
for i, p := 0, (*int)(nil); p == nil; println(p == &i) {
p = &i
}
}
What did you see happen?
What did you expect to see?
Note that when the -gcflags=-lang=go1.22 compiler flag is specified, then the "//go:build go1.xy" comment directive is respected (go run . with a go.mod file also respects it).
$ gotv 1.22. run main.go
[Run]: $HOME/.cache/gotv/tag_go1.22.0/bin/go run main.go
false
$ gotv 1.22. run -gcflags=-lang=go1.22 main.go
[Run]: $HOME/.cache/gotv/tag_go1.22.0/bin/go run -gcflags=-lang=go1.22 main.go
true
$ gotv 1.22. run .
[Run]: $HOME/.cache/gotv/tag_go1.22.0/bin/go run .
true
$ gotv 1.22. run -gcflags=-lang=go1.22 .
[Run]: $HOME/.cache/gotv/tag_go1.22.0/bin/go run -gcflags=-lang=go1.22 .
true
Go version
go version go1.22.0 linux/amd64
Output of
go envin your module/workspace:.What did you do?
main.go:
What did you see happen?
What did you expect to see?
Note that when the
-gcflags=-lang=go1.22compiler flag is specified, then the "//go:build go1.xy" comment directive is respected (go run .with a go.mod file also respects it).