-
Notifications
You must be signed in to change notification settings - Fork 18.1k
go/build: MatchFile excludes x_js.go when GOOS != js #26424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Approximately a dup of #26329, though there we just documented this change. If we change this, presumably by removing We could consider changing the |
The specific case where this arises in Google is that we have a go-bindata-like tool that reads x.js and writes x_js.go. Looking at the public go-bindata, though, it just writes one file bindata.go, which doesn't hit this problem. I'm also looking through a very large GOPATH with tons of packages pulled in, and it looks like there are at least a few external projects that already had *_js.go files for use with GopherJS. It may be that we can leave this as-is and document. I'll report back once I have more data (still downloading). |
I think we should explicitly and prominently document that naming files with underscores that aren't instructions to Personally, I really like the feature of naming files with os/arch and I'd dislike it if we moved in the direction of requiring explicit build tags in more situations. |
FWIW we did document this in the release notes: https://tip.golang.org/doc/go1.11#wasm |
If we go that route then I would argue that Go 2 should always interpret files with underscores as containing build instructions, regardless of the current set of GOOS values. |
I am not convinced we should disallow all use of underscores except for GOOS/GOARCH. I think it would be fine for a project to have storage_aws.go, storage_azure.go, etc. If we do put the go version into the module file (#23969) then the go command could set the GOOS/GOARCH list appropriately when looking at files in that module. That would future-proof things (at least as far as not breaking builds) without imposing additional requirements on users. Back to the question of how common the _js suffix is. I have a list of the most commonly imported ~1000 open source repos that I use for testing vgo, plus ~100 of the projects that import the most other things. Scanning those repos and their dependencies, I found:
It looks like these are all for GopherJS or the new wasm/js support:
That suggests it's fine to document and close (already done). |
#102835 adds "js" to build.goosList, causing build.Context.MatchFile to exclude files named
*_js.go
when GOOS is not "js".We have a number of existing files that match that pattern (mostly generated code containing embedded JavaScript strings), and there are probably more in the world at large. This seems like it might be too common a suffix to change at this time.
The text was updated successfully, but these errors were encountered: