Using depguard: https://github.com/OpenPeeDeeP/depguard in golangci-lint.
Example: https://github.com/open-telemetry/opentelemetry-go/blob/bb5b0a8e61deb5ed46cb99abc17de3565b168d23/.golangci.yml#L38-L48
settings:
depguard:
rules:
non-tests:
files:
- '!$test'
- '!**/*test/*.go'
- '!**/internal/matchers/*.go'
deny:
- pkg: testing
- pkg: github.com/stretchr/testify
- pkg: crypto/md5
- pkg: crypto/sha1
- pkg: crypto/**/pkix
More discussion on Slack.
Using
depguard: https://github.com/OpenPeeDeeP/depguard in golangci-lint.Example: https://github.com/open-telemetry/opentelemetry-go/blob/bb5b0a8e61deb5ed46cb99abc17de3565b168d23/.golangci.yml#L38-L48
More discussion on Slack.