Hi Folks,
Constraints may appear in any kind of source file (not just Go), but they must appear near the top of the file, preceded only by blank lines and other line comments.
The
current implementation (and presumably all past implementations) explicitly enforces the constraint that a preceding general (i.e. non-line) comment is not permitted.
Does anyone remember the rationale for that? Something to do with avoiding undesired coincidental matching of comments in non-Go files? I've done a little forensic digging, but it quickly gets tricky as the code originated in cmd/vet.
I ran across this recently when attempting to insert a build constraint into some of our existing Go code with a boilerplate corporate copyright which started life in C/C++ source files. It took me quite a while to figure out what was going on.... :-)
Regards,
Neil