Discussing with @matloob, we were surprised that https://go.dev/doc/toolchain was the best (only?) canonical documentation we could find for the fact that //go:build go1.22
is not just a build constraint, but also affects the language version within that file.
We should make this more apparent in documentation, by including this information in (at least) go help buildconstraint
. It may also be worth mentioning this in go.dev/ref/mod
, or other go command documentation.
Comment From: gabyhelp
Similar Issues
- doc: mention language downgrading via `//go:build` #61894
- cmd/go: go directive is insufficiently documented for module authors to be able to make a decision about its value #30791
- cmd/go, cmd/compile: record language version to support language transitions #28221
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: findleyr
Helpful @gabyhelp.
Not yet closing as a dupe of #61894 (though it's very closely related), since this issue is about a specific go command help page. But feel free to close this if you'd prefer.
Comment From: gopherbot
Change https://go.dev/cl/595475 mentions this issue: cmd/go/internal/help: add documentation for language version downgrading