tomarrell / wrapcheck

A Go linter to check that errors from external packages are wrapped
https://blog.tomarrell.com/post/introducing_wrapcheck_linter_for_go
MIT License
291 stars 26 forks source link

Support for ignoring regular match files #41

Closed shuqingzai closed 5 months ago

shuqingzai commented 1 year ago

For example, the methods in a bootstrap.go are all used to start the program, and I just want to process them uniformly at the location where the service starts, instead of wrapping each function

image

Currently, I need to handle something like the following, too many nolint:wrapcheck flags, not very friendly

image

tomarrell commented 1 year ago

G'day @shuqingzai, thanks for the suggestion.

Are you using golangci-lint? If you are, you can exclude certain linters reporting errors for specific files using exclude rules.

https://golangci-lint.run/usage/configuration/

e.g.

  exclude-rules:
    # Exclude some linters from running on tests files.
    - path: _test\.go
      linters:
        - gocyclo
        - errcheck
        - dupl
        - gosec

I'm not opposed to adding the functionality, as it would be backwards compatible, but given this can be achieved using golangci-lint, I would first ask if you're using that.