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

feat: support searching for config in XDG_CONFIG_HOME and $HOME/.config #4974

Closed
wants to merge 1 commit into from

Conversation

k4yt3x
Copy link

@k4yt3x k4yt3x commented Sep 3, 2024

This code will, in addition to the current directories being searched, also look for the config file in XDG_CONFIG_HOME/golangci and $HOME/.config/golangci.

For desktop applications, I find it not very elegant to leave the .golangci.yml in my home directory. I usually prefer to put config files in XDG_CONFIG_HOME ($HOME/.config) to avoid making a mess in the home directory. I do not want to manually specify a config path with --config since it will overwrite the repository's config if one exists. I reviewed the code and found that golangci-lint does not seem to support finding the config in XDG_CONFIG_HOME, so I'm submitting this PR in recommendation of adding this support.

Setup

I have a configuration file located at $HOME/.config/golangci/golangci.yml. I am using golangci-lint's repository for the demo below. I have removed the repository's built-in .golangci.yml so it will search for the global config.

Previous Behavior

Previously, golangci-lint does not search for the said directories above, only $HOME:

image

New Behavior

Now, if the old recursive search does not yield any results, it will also search the global config directories:

image

...and if we restore the repo config it still finds that first:

image

Fixes #4554

Copy link

boring-cyborg bot commented Sep 3, 2024

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link

CLAassistant commented Sep 3, 2024

CLA assistant check
All committers have signed the CLA.

@k4yt3x k4yt3x marked this pull request as ready for review September 3, 2024 23:07
@ldez ldez added the declined label Sep 3, 2024
@ldez
Copy link
Member

ldez commented Sep 3, 2024

related to #4554

I suggest looking for the issues or creating an issue before opening this type of PR.

@ldez ldez closed this Sep 3, 2024
@k4yt3x
Copy link
Author

k4yt3x commented Sep 4, 2024

I suggest looking for the issues or creating an issue before opening this type of PR.

I actually did search, for both issues and PRs, neither returned what I was looking for.

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

Successfully merging this pull request may close these issues.

Support local .config
3 participants