-
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: How can I prevent go CLI to check all dependencies before doing actions #26660
Comments
@sneko You can try |
Hi @sneko, slightly expanding on the answer from @oiooj , here are related some snippets from the module docs on tip:
And the doc section on build flags includes listing the commands you asked about (
In addition, #26585 and change https://golang.org/cl/126656 describe a related possible enhancement that is targeted at multiple use cases, including specifying -getmode in CI via an environmental variable. Snippet from the CL:
Is your concern addressed at this point? If so, does it make sense to close this issue? |
And just to be a bit more explicit, one more comment is that as of right now #26585 is still open and change https://golang.org/cl/126656 with $GOFLAGS is still in progress / not yet merged, so of course some chance it might not land and/or change in some way before it lands. |
@oiooj @thepudds thank you very much for the help and these explanations! I missed this part in the documentation :s I've still an issue with the To be more clear, my project (=module) imports X, Y, Z as external packages, and after running Do I missed something to do...? EDIT:
It's like if it doesn't understand being inside the module that it is looking for... That's the same when running |
My bad...! Since I was putting my final executable in an alpine image I had to build my project with the But the flip side is that some unit and coverage tests are not working at all with musl libs so I had to run them inside a "non-alpine" image. That's what I did by putting I'm sorry for posting this stupid "issue" 😀 Thank you again for your help on the main issue! |
What version of Go are you using (
go version
)?go version go1.11beta2 windows/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
I'm trying to execute basic Go commands in a CI/CD environment. The idea is that I have 2 stages representing "BUILD stage" and "TEST stage", so they are totally running in different docker instances while the project directory (= workspace) is the same between both.
In the BUILD stage I first download all project dependencies written in my go.mod and then I run a "go mod -vendor" to copy them from the $GOPATH to a "vendor" subdirectory of my project. Like that in the next TEST stage there is potentially no need to download again all the dependencies.
To tell you more about the context I run some basic commands like:
Installing global dependecy:
go get -u github.com/jteeuwen/go-bindata/...
Make unit tests:
go test ./...
Make a coverage test:
go test -race -cover ./...
What did you expect to see?
I would require these commands to just do their job without trying to check dependencies.
What did you see instead?
Instead, for each of these commands I get something like:
It means that the CLI makes a request to each repository to check the version... and it takes a lot of time while they are already in the vendor directory matching the go.mod requirements!
I guess since there is an empty directory at $GOPATH because this one is not passed from the BUILD stage to TEST stage, the CLI changes its behavior. But there is no reason to...
I succeeded to work around while installing global dependency (
go get github.com/jteeuwen/go-bindata/...
):-u -f
parameters according the docs to avoid these checksGO111MODULE=off go get -u -f github.com/jteeuwen/go-bindata/...
That's not a cleanest way but it works...
At this time I didn't find a solution for either
go test ./...
andgo test -race -cover ./...
.One of the solution could be to mount a volume on $GOPATH to have downloaded dependencies from BUILD stage inside the TEST stage but that's not a clean way too. And if you think it is, what is the purpose of
go mod -vendor
if the CLI cannot manage correctly vendored dependencies?I hope I was clear in my explanations, don't hesitate to ask more information. Maybe @rsc you have an idea about this since I'm using the latest features coming from vgo.
Thank you 😃 !
The text was updated successfully, but these errors were encountered: