chore: add depguard config for linter #337
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See https://github.com/Kong/go-kong/actions/runs/5171929210/jobs/9315785132?pr=333 for example problem.
golangci-lint version 1.53 upgraded the depguard linter from v1 to v2. AFAICT v1's behavior with no configuration to allow all packages, whereas v2 apparently denies everything but the standard library and local files (unclear--I'm not sure where the defaults actually live and the depguard change logs do not mention this, but it appears to be the case from my testing). golangci/golangci-lint#3795 (comment) agrees but doesn't indicate the cause of the default change.
The presence of a denylist will instead deny only those packages and allow all others. The tests I can find in golangci-lint appear to all use a denylist and may be missing the default behavior, and it's possible nobody noticed the issue because it was masked by some other issue where depguard was preventing the linter from running at all :|
I don't entirely agree that this is a "reasonable" default and have half a mind to just remove it, but seeing as we need to make changes to the golangci-lint config either way, we may as well list some basic packages we should never include instead.
Edit: subsequently, I found that elsewhere we did remove it, and that we're also using gomodguard in some cases, which seems to provide nigh-identical functionality. Since we don't use the depguard globbing and gomodguard appears to maybe some additional features re suggestions, using that instead.