-
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: build: add -buildmode=nolink flag #31710
Comments
See also fatih/vim-go#2245. |
Another update, the slowness only reproduces when compiling a main package, otherwise it's fast. |
This is taking advantage of build caching. |
Ah, thanks Russ! |
Hi, Is this possibly be accepted, I am making a patch to implement this. |
I'm not sure that this is really relevant anymore thanks to the proliferation of |
Thank you @zikaeroh . I'm cursor how gopls do that,does it invoke |
It uses |
Seems |
I propose we allow
We can just extend that to main packages as well, to mean "compile but not link", and optionally generate the .a file. As a compiler/linker developer, from time to time I want the main.a file. Currently I have to do |
My understanding of the "go build" process is it does something like this:
.a
file or equivalent in$GOPATH/pkg
..a
file or similar) we checked in net: LookupHost is returning odd values and crashing net tests #2 that is now out of date.I use
vim
to edit Go files. The most popular plugin,vim-go
, recommends checking compilation by running:GoBuild
. I do this frequently to ensure I have syntax correct, imports correct, a working Go program.:GoBuild
changes directory to the directory containing the file you are editing, then runsIt builds the "errors" package because vim-go desperately does not want to build any final artifacts, and attempting to build multiple packages turns off the binary building behavior.
However, I notice that this never takes advantage of build caching. That is, if I run
:GoBuild
and then run:GoBuild
again immediately without making changes, it takes 4 seconds on the package I am compiling. If I rungo build .
to compile an artifact, it is much faster, about 600ms on the second run.Is there a way to make "go build" take advantage of whatever intermediate build steps exist - the
.a
files from above, or their equivalents - even if it does not produce a final binary?Alternatively, can you work with the
vim-go
maintainers to recommend a different tool for checking a package (and/or test package) contains valid Go syntax and identifiers?The text was updated successfully, but these errors were encountered: