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

Configurable cache directory #1690

Closed
calvinbui opened this issue Feb 5, 2021 · 6 comments
Closed

Configurable cache directory #1690

calvinbui opened this issue Feb 5, 2021 · 6 comments
Labels
enhancement New feature or improvement

Comments

@calvinbui
Copy link

Is your feature request related to a problem? Please describe.
A configuration option to set the caching directory. By default it goes to ~/.cache/golangci-lint on Linux and ~/Library/Caches/golangci-lint on Mac

Describe the solution you'd like
The caching directory option via the run command or config file

Describe alternatives you've considered
N/A

Additional context
N/A

@calvinbui calvinbui added the enhancement New feature or improvement label Feb 5, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Feb 5, 2021

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@AlekSi
Copy link
Contributor

AlekSi commented Mar 25, 2021

Currently, it is possible to configure the cache directory via GOLANGCI_LINT_CACHE environment variable. But it is not documented (#734), and also not a flag or config file field requested by OP.

@ldez
Copy link
Member

ldez commented Mar 25, 2021

// DefaultDir returns the effective GOLANGCI_LINT_CACHE setting.
func DefaultDir() string {
// Save the result of the first call to DefaultDir for later use in
// initDefaultCache. cmd/go/main.go explicitly sets GOCACHE so that
// subprocesses will inherit it, but that means initDefaultCache can't
// otherwise distinguish between an explicit "off" and a UserCacheDir error.
defaultDirOnce.Do(func() {
defaultDir = os.Getenv("GOLANGCI_LINT_CACHE")
if filepath.IsAbs(defaultDir) {
return
}
if defaultDir != "" {
defaultDirErr = fmt.Errorf("GOLANGCI_LINT_CACHE is not an absolute path")
return
}
// Compute default location.
dir, err := os.UserCacheDir()
if err != nil {
defaultDirErr = fmt.Errorf("GOLANGCI_LINT_CACHE is not defined and %v", err)
return
}
defaultDir = filepath.Join(dir, "golangci-lint")
})
return defaultDir
}

Introduced in #699

@ldez ldez closed this as completed Mar 25, 2021
@AlekSi
Copy link
Contributor

AlekSi commented Mar 25, 2021

Not sure why close it if not a single point from #1690 (comment) is addressed.

@ldez
Copy link
Member

ldez commented Mar 25, 2021

Because I reopened #734 and created a PR #1871

@AlekSi
Copy link
Contributor

AlekSi commented Mar 25, 2021

Sorry, I don't follow.

Describe the solution you'd like
The caching directory option via the run command or config file

The environment variable is not a run command flag or config file field.

If you don't think flag/field is a good idea for some reason, explicitly saying so would send a much clear signal than closing an issue with a comment that looks like the issue wasn't really read beyond the title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants