Skip to content
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

Set a default env var for GOMODCACHE. #880

Merged
merged 1 commit into from
Dec 8, 2023
Merged

Conversation

dlorenc
Copy link
Member

@dlorenc dlorenc commented Dec 8, 2023

Melange supports a filesystem based cache, but it's not used anywhere AFAICT. To use it for Go, we've documented how to set this env var. Instead of making everyone set it in every pipeline and build, let's just set it to the correct path by default in melange itself.

This dramatically improves build times for me.

Melange Pull Request Template

Functional Changes

  • This change can build all of Wolfi without errors (describe results in notes)

Notes:

Melange supports a filesystem based cache, but it's not used anywhere AFAICT.
To use it for Go, we've documented how to set this env var. Instead of making
everyone set it in every pipeline and build, let's just set it to the correct
path by default in melange itself.

This dramatically improves build times for me.

Signed-off-by: Dan Lorenc <[email protected]>
if cfg.Environment.Environment["GOPATH"] == "" {
cfg.Environment.Environment["GOPATH"] = defaultEnvVarGOPATH
var setIfEmpty = func(key, value string) {
if cfg.Environment.Environment[key] == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a pointless idea, but there's a chance it's better to use the , ok = style of check for map value emptiness rather than an empty string, in case we think the user would ever want to explicitly control the env variable to be empty at some point.

@dlorenc dlorenc merged commit b83ec1e into chainguard-dev:main Dec 8, 2023
29 checks passed
@dlorenc dlorenc deleted the cache branch December 8, 2023 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants