You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
by borman@google.com:
The text was updated successfully, but these errors were encountered: