cmd/go: build constraints disparity between compiler and documentation #63502
Labels
Documentation
FrozenDueToAge
GoCommand
cmd/go
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?Tested with go1.20 and go1.21
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?Included, though I doubt it has an impact:
go env
OutputWhat did you do?
The documentation for build constraints states that constraints
However, during experimentation it became apparent that
//go:build
directives are honored even after blockcomments. This didn't seem to hold true for the older
//+build
form.I reached out to gophers slack's
#tools
channel for their input, and they thought it'd beworth filing an issue.
dominikh
created https://go.dev/play/p/5jqlmjNEjOH.go showing hisresults, which match mine.
What did you expect to see?
That the compiler and documentation match. If the current docs are correct, the compiler would ignore build constraints if proceeded by things other than line comments, while if the current compiler is correct, that the docs describe what the compiler allows.
For example, the docs seem to imply that the constraint should be ignored:
What did you see instead?
//go:build
is honored even if following block comments.Note: the old style
//+build
is ignored after block comments, matching the documentation.The text was updated successfully, but these errors were encountered: