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

depguard doesn't seem to respect configuration #93

Open
ptokarski opened this issue May 8, 2024 · 1 comment
Open

depguard doesn't seem to respect configuration #93

ptokarski opened this issue May 8, 2024 · 1 comment

Comments

@ptokarski
Copy link

ptokarski commented May 8, 2024

$ golangci-lint --version
golangci-lint has version v1.57.2 built with go1.22.2 from (unknown, modified: ?, mod sum: "h1:NNhxfZyL5He1WWDrIvl1a4n5bvWZBcgAqBwlJAAgLTw=") on (unknown)

main.go:

package main

import _ "github.com/lib/pq"

func main() {}

go.mod

module main

go 1.22.2

require github.com/lib/pq v1.10.9

go.sum

github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=

.golangci.yml

linters:
  enable:
    - depguard

.depguard.yml

Main:
  files:
    - $all
    - "!$test"
  allow:
    - $gostd
    - github.com/lib/pq
  deny:
    reflect: Please don't use reflect package
Test:
  files:
    - $test
  allow:
    - $gostd
    - github.com/stretchr/testify
  deny:
    reflect: Please don't use reflect package

invocation:

$ golangci-lint run
main.go:3:8: import 'github.com/lib/pq' is not allowed from list 'Main' (depguard)
import _ "github.com/lib/pq"
       ^

I think I did everything as it is describe in the docs. Expected not to see an issue.

@ptokarski ptokarski changed the title Project does not respect configuration files depguard doesn't seem to respect configuration May 8, 2024
@dixonwille
Copy link
Member

When using golangci-lint, you should use their configuration file to configure depguard. Here is an example pulled for your specific verison of golangci-lint. https://github.com/golangci/golangci-lint/blob/77a8601aa372eaab3ad2d7fa1dffa71f28005393/.golangci.reference.yml#L210

Please respond back after making these changes whether or not moving the configuration into golangci-lint's configuration works.

https://github.com/OpenPeeDeeP/depguard?tab=readme-ov-file#golangci-lint

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

No branches or pull requests

2 participants