go/build: file name build constraints incorrect when name contains dots #46662
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I created a
.go
file which contained dots in the name along with a_GOOS
extension (e.g.file.name_darwin.go
)What did you expect to see?
I expected this file to be compiled only when
GOOS=darwin
Please see this example, which I expect to compile but does not:
https://github.com/knusbaum/goissue/
What did you see instead?
The error that appears:
Additional information
The build constraint documentation says this:
Wherever a file's "extension" is mentioned in the Go documentation, it means whatever comes after the final
.
in the file name. This is also what path.Ext documents and computes.However, the os/arch-matching code takes the extension from the first instance of
.
rather than the last, as the documentation would lead me to expect.This places requirements for using the os/arch constraints in file names that are not documented anywhere and are inconsistent with the way Go code and documentation usually deals with file extensions.
The text was updated successfully, but these errors were encountered: