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

imports: add handling of whitelists #8

Merged
merged 4 commits into from
Aug 6, 2018
Merged

imports: add handling of whitelists #8

merged 4 commits into from
Aug 6, 2018

Conversation

kortschak
Copy link
Member

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.

@kortschak kortschak force-pushed the whitelist branch 2 times, most recently from 90cd082 to bc7ea0e Compare July 27, 2018 07:31
@@ -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
Copy link
Member

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/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

}

// str returns a slice of patterns matching the standard library.
func std() ([]string, error) {
Copy link
Member

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.")

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

@sbinet
Copy link
Member

sbinet commented Jul 27, 2018

I am ok with automatically adding "std" to the whitelist.
but couldn't we handle the "-std" as "std" being added to the blacklist?

}

// str returns a slice of patterns matching the standard library.
func std() ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

return append(list, pkgs...), nil
}

// str returns a slice of patterns matching the standard library.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/str/std/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@kortschak
Copy link
Member Author

couldn't we handle the "-std" as "std" being added to the blacklist?

That doesn't allow quite the same set of operations. If you have -w="-std,math,fmt", you can't express that easily by -b=..... The issue here is that the "-std" is preventing addition to the whitelist rather than blacklisting the std.

@kortschak
Copy link
Member Author

PTAL

@kortschak kortschak merged commit bb32599 into master Aug 6, 2018
@kortschak kortschak deleted the whitelist branch September 5, 2018 07:24
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

Successfully merging this pull request may close these issues.

{cmd/,}imports: add whitelisting
2 participants