-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: Allow go mod cache location to be overridden, e.g. GOMODCACHE (for CI purposes) #31283
Comments
/cc @bcmills |
Why is it important that the cache location to be independent of |
You could also change |
It was basically more like a question. I am coming from the old I'm currently overthinking my whole suggestion and writing down my thoughts:
I could see this closed, I was thinking too much "the old way" and there's no technical requirement as of now |
Here's a reason I think this could be helpful. With Unfortunately, many environments explicitly set The answer here could be "simply override the This would indeed be fixed by a |
@dionysius you can copy the cache inside the project folder and then cache it with gilabci -- before building you move the cache back in $GOPATH/pkg/mod e.g. or use vendor and set in ci:
|
What if I would like to set the cache on a RAMDISK (and not wear the SSD)? |
@TudorHulban GOMODCACHE was implemented in #34527, and it will ship with Go 1.15. |
Wooooow! Good to hear! |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No documentation about wished behaviour found
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you expect?
There seem not to exist something what I'd like to do (yet). The issue is, freshly loading all dependent modules can take some time and network I/O. If the CI jobs are split into each type, all of them load concurrently the same cache for their own lifetime - think of: unit-test, unit with race, linting, building, all separated. And if each job is spawned from a clean golang image, like with docker for example, the cache starts empty.
In Gitlab, the cache option can be used, but must be within the projects source dir. I already used the cache option once for
GOCACHE
andGODEPCACHE
(i believe the env name was that) to overwrite their location to my liking. But I seem unable to set the cache path for modules. How about aGOMODCACHE
env, which would be used if non-empty?I know that the mod cache dir is in
$GOPATH/pkg/mod
, but changing the fullGOPATH
to somewhere within the source folder seems off to me.The text was updated successfully, but these errors were encountered: