-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: go:generate causes unnecessary packages in std & binary releases #31920
Comments
Change https://golang.org/cl/176019 mentions this issue: |
The
To clarify, did you mean it's not possible to |
If the person has to think about or research which flags to |
Wait, from the design doc, https://golang.org/s/go1.4-generate
So that was the plan! But it wasn't implemented it seems:
|
I looked at Go 1.4 and Go 1.5 and neither supported adding the "generate" build tag for file selection, so it's not like we accidentally deleted it at some point. I guess it was just never done. |
Change https://golang.org/cl/175984 mentions this issue: |
Change https://golang.org/cl/175983 mentions this issue: |
Updates #31920 Change-Id: Ie24ed5bab249e2f90d1740f42a8b8d94fd0983f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/176019 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Change https://golang.org/cl/175899 mentions this issue: |
I'm not sure this is true in general; some generators rely on build tags because they rely on type information. Hence they rely on the values of We're wrestling with this problem in golang-tools world; not only for In the case of Considering |
cmd/go supports the "generate" build tag as of CL 175983. Add it to the files which are just used for generating errors and syscall wrappers. Also see golang/go#31920 Change-Id: Ib26c90af0ac1fb7bae81366a46dedf028b787566 Reviewed-on: https://go-review.googlesource.com/c/sys/+/175899 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The latest change on Go tip [1] somehow make the "go generate" with "+build generate" on main package cause an error, can't load package: package github.com/shuLhan/ciigo: found packages ciigo (ciigo.go) and main (generate_main.go) in /home/ms/go/src/github.com/shuLhan/ciigo From the source code of Go itself, seems like the correct directive is "+build ignore" instead of "+build generate". [1] golang/go#31920
I notice that on non-Windows platforms, the Windows-only
internal/syscall/windows/registry
gets listed ingo list std
and gets shipped in binary releases:Likewise with
internal/syscall/windows
.That's all because of the packages having a single go file that's not behind
+build windows
:No code. Just a "go generate" line.
If we made that file
+build windows
, then we couldn't run "go generate" on Linux. Is that useful? Probably.Perhaps we could make it
+build generate
and havego generate
add thegenerate
build tag?/cc @robpike @alexbrainman @ianlancetaylor @josharian @rsc @bcmills @dmitshur
The text was updated successfully, but these errors were encountered: