OpenPeeDeeP / depguard

Go linter that checks if package imports are in a list of acceptable packages.
GNU General Public License v3.0
138 stars 15 forks source link

Add current module name to allow list #66

Open mirecl opened 11 months ago

mirecl commented 11 months ago

More info in PR for https://github.com/golangci/golangci-lint/pull/4098

dixonwille commented 10 months ago

I like the idea of being explicit over implicit. I agree with Idez in this scenario, magic configs cropping up is not good. The reason why go.mod is allowed when no allow list is supplied is because this package assumed without an allow everything was allowed. Once you specified allowed, it went into a strict mode situation where everything is denied.

I just recently pushed a change to V2 that lets you determine the mode Strict vs Lax. I have not tagged it yet as I am trying to cleanup a few Issues before I do.

I can compromise by adding a $gomodname variable, but I don't see what that gives you outside of just putting it in the list (maybe the ability to reuse configs by module).

dixonwille commented 10 months ago

I am going to add the $gomodname variable in as I have a few other issues that require additional variables. That will be in the v2.2.0 release

ldemailly commented 10 months ago

I'll second that having depguard on for a package with 0 dependency yet getting

env_test.go:9:2: import 'fortio.org/struct2env' is not allowed from list 'Main' (depguard)
    "fortio.org/struct2env"
    ^

when that's the module path is weird

the default config should at least work for "0 dep" packages where 0 deps still means the test package can test the module