-
Notifications
You must be signed in to change notification settings - Fork 3
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
imports: add handling of whitelists #8
Conversation
90cd082
to
bc7ea0e
Compare
cmd/check-imports/main.go
Outdated
@@ -2,13 +2,17 @@ | |||
// Use of this source code is governed by a BSD-style | |||
// license that can be found in the LICENSE file. | |||
|
|||
// Command check-imports inspects a source tree for blacklisted imports. | |||
// Command check-imports inspects a source tree for imports satisfying a | |||
// whitelist/blacklist scheme. If a whitelist in included, packages from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/in included/is included/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed.
imports/imports.go
Outdated
} | ||
|
||
// str returns a slice of patterns matching the standard library. | ||
func std() ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively, this could be pre-generated with a //go:generate go list std
directive.
(one for each Go version we support, "of course.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a lower maintenance burden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
I am ok with automatically adding |
imports/imports.go
Outdated
} | ||
|
||
// str returns a slice of patterns matching the standard library. | ||
func std() ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
imports/imports.go
Outdated
return append(list, pkgs...), nil | ||
} | ||
|
||
// str returns a slice of patterns matching the standard library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/str/std/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
That doesn't allow quite the same set of operations. If you have |
PTAL |
This adds whitelist/blacklist handling. I'm not sure about the approach to std; at the moment it adds std to the whitelist if there is one. The two other options are to have pseudo-packages to specify inclusion or exclusion of std ("std" and "-std" respectively). I think requiring "std" to be added for whitelisting is probably too onerous, so that just leaves a "-std" for cases where std should be removed from the whitelist,... or just leaving it how it is. Thoughts?
Please take a look.
Closes #4.