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

dev: add GL_DEBUG=govet to see enabled analyzers #4465

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

alexandear
Copy link
Member

The PR adds the debug key govet that can be used to see default, all available, and enabled govet analyzers:

GL_DEBUG=govet ./golangci-lint run --enable=govet

Example of debug output:

❯ GL_DEBUG=govet ./golangci-lint run --enable=govet
DEBU [govet] All available analyzers (41): [appends asmdecl assign atomic atomicalign bools buildtag cgocall composites copylocks deepequalerrors defers directive errorsas fieldalignment findcall framepointer httpresponse ifaceassert loopclosure lostcancel nilfunc nilness printf reflectvaluecompare shadow shift sigchanyzer slog sortslice stdmethods stringintconv structtag testinggoroutine tests timeformat unmarshal unreachable unsafeptr unusedresult unusedwrite] 
DEBU [govet] Default analyzers (32): [appends asmdecl assign atomic bools buildtag cgocall composites copylocks defers directive errorsas framepointer httpresponse ifaceassert loopclosure lostcancel nilfunc printf shift sigchanyzer slog stdmethods stringintconv structtag testinggoroutine tests timeformat unmarshal unreachable unsafeptr unusedresult] 
DEBU [govet] Enabled by config analyzers (35): [appends asmdecl atomicalign bools buildtag cgocall composites copylocks deepequalerrors defers directive errorsas fieldalignment findcall framepointer httpresponse ifaceassert loopclosure lostcancel nilfunc printf reflectvaluecompare shift sigchanyzer slog sortslice stdmethods stringintconv structtag testinggoroutine tests timeformat unmarshal unreachable unsafeptr] 

The implementation of govet output debugging is similar to the existing one for gocritic checks.

Previously, the documentation suggested using go tool vet help to see all analyzers. However, this might be inaccurate as we could forget to update govet.allAnalyzers and govet.defaultAnalyzers slices. To avoid this, I changed the documentation to GL_DEBUG=govet golangci-lint run --enable=govet.

@ldez ldez self-requested a review March 7, 2024 13:11
@ldez ldez added area: docs linter: update Update the linter implementation inside golangci-lint labels Mar 7, 2024
@ldez ldez added this to the next milestone Mar 7, 2024
Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

@ldez ldez merged commit 4fea092 into golangci:master Mar 7, 2024
12 checks passed
@alexandear alexandear deleted the dev-debug-govet branch March 7, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: docs linter: update Update the linter implementation inside golangci-lint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants