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/imports: remove duplicate imports when one is _-imported #42432

Closed
josharian opened this issue Nov 6, 2020 · 2 comments
Closed

x/tools/imports: remove duplicate imports when one is _-imported #42432

josharian opened this issue Nov 6, 2020 · 2 comments
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@josharian
Copy link
Contributor

If you run goimports on this code:

package p

import (
  _ "crypto/sha1"
)

var _ = sha1.Sum

You get:

package p

import (
	"crypto/sha1"
	_ "crypto/sha1"
)

var _ = sha1.Sum

Note the duplicate imports. We could remove the _ import.

@josharian josharian added this to the Unreleased milestone Nov 6, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Nov 6, 2020
@FiloSottile
Copy link
Contributor

Note that https://golang.org/cl/250497 was reverted in https://golang.org/cl/265078, because while the naked import might be removed if the package is not explicitly used anymore, the _ import expresses the intention to import it regardless. goimports should probably preserve that.

@josharian
Copy link
Contributor Author

Ah, makes sense. Thanks.

@golang golang locked and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants