I agree about gofmt sorting the imports.
I am skeptical about mimicking Eclipse. In particular:
> import (
> "bytes";
> "flag";
> "fmt";
> "io";
> "os";
> foo "path";
> "strings";
>
> "go/parser";
> "go/printer";
> "go/scanner";
> )
This example doesn't really apply, because "go/" is a package
hierarchy, not a separate project. If I import "container/vector"
does that go into its own block? What about "hash/crc32"?
The general idea is good, though. For programs we write inside
Google, we have taken to organizing the imports as two blocks
as above, except the distinction is between standard packages
and google-internal packages (all of which have a distinguishing
google prefix).
I think we still need more time to experiment before codifying
something in gofmt, but I expect that gofmt will eventually do
something along these lines. One possibility would be to split
the import block into chunks separated by blank lines (or
comment-only lines) and then have gofmt sort the individual
chunks. Then it would be up to the programmer to categorize
the imports according to local convention, and gofmt would just
sort the categories.
Russ