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

go.tools/import: goimports does not correctly handle "." includes. #7365

Closed
gopherbot opened this issue Feb 20, 2014 · 2 comments
Closed

go.tools/import: goimports does not correctly handle "." includes. #7365

gopherbot opened this issue Feb 20, 2014 · 2 comments

Comments

@gopherbot
Copy link

by borman@google.com:

The following program (http://play.golang.org/p/xs_zl5_ksk) has been run through
goimports:

    package main

    import . "os"

    func main() {}

The import line should have been removed.  Seen both on the play.golang.org and go
version go1.2 linux/amd64.
@robpike
Copy link
Contributor

robpike commented Feb 21, 2014

Comment 1:

Labels changed: added repo-tools.

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

Comment 2:

Good bug report, but I don't think this is worth fixing.  At least, not in the general
case.
goimport's fast path doesn't do any on-disk lookups or parsing of Go code to figure out
whether an import was used.
Answering this question for the example given would require we lookup all the symbols in
"os".  Fortunately we do keep the standard library in memory, so it's possible we could
at least support this feature for some packages.
But:
*) I don't like doing this "." magic for some packages (stdlib) and not others.  (Why
wouldn't this work for dot imports of unit tests in your own packages?)
*) dot imports are weird and discouraged anyway.  I prefer the existing behavior of just
always keeping them.  Once a dot import is there, it's unlikely it's ever going away
(it's in a test package testing your internals, so surely you're not just deleting all
your tests and leaving only the imports, right?)
If you disagree or have a less contrived example that actually bit you, we could re-open
or fix in a different way.

Status changed to WontFix.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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