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

x/tools/cmd/goimports: unnecessary PackageName in ImportSpec #18027

Closed
mdempsky opened this issue Nov 23, 2016 · 5 comments
Closed

x/tools/cmd/goimports: unnecessary PackageName in ImportSpec #18027

mdempsky opened this issue Nov 23, 2016 · 5 comments

Comments

@mdempsky
Copy link
Member

$ printf 'package p\nvar _ = sheets.SpreadsheetsReadonlyScope\n' | goimports
package p

import sheets "google.golang.org/api/sheets/v4"

var _ = sheets.SpreadsheetsReadonlyScope

The package name is already sheets, so there's no need to explicitly name it.

/cc @bradfitz

@mdempsky mdempsky added this to the Unreleased milestone Nov 23, 2016
@bradfitz
Copy link
Contributor

Intentional.

It's more explicit. And it makes future goimports runs faster, not having to scan the "v4" directory to figure out what it means.

@mdempsky
Copy link
Member Author

Seems inconsistent that it leaves import "google.golang.org/api/sheets/v4" alone.

@bradfitz
Copy link
Contributor

I don't follow. You didn't say anything about that in your bug report.

@mdempsky
Copy link
Member Author

$ printf 'package p\nimport "google.golang.org/api/sheets/v4"\nvar _ = sheets.SpreadsheetsReadonlyScope\n' | goimports
package p

import "google.golang.org/api/sheets/v4"

var _ = sheets.SpreadsheetsReadonlyScope

@bradfitz
Copy link
Contributor

I still think it's fine. That is: don't mess with people's existing imports if they wrote them by hand or tweaked them by hand. But if we're adding them automatically, then we get to remind them of convention. (dir name == package name) If they don't follow convention, we help readers out. If they don't like it, they can delete it or follow convention.

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

No branches or pull requests

3 participants