mirror of
https://github.com/golang/go
synced 2024-11-18 14:14:46 -07:00
The Go programming language
84a35ef54d
Before this change, astutil would only do a prefix match of a new import with all the existing ones, to try to place it in the correct group. If none was found, the new import would be placed at the beginning of the first import group. This works well for new std imports, but it doesn't work well for new third-party packages that don't share any prefix with any of the existing imports. Example: import ( "time" "github.com/golang/snappy" ) When adding "golang.org/x/sys/unix" with astutil.AddImport, the import is inserted as follows: import ( "golang.org/x/sys/unix" "time" "github.com/golang/snappy" ) And goimports reorganizes the imports to separate std and third-party packages: import ( "time" "golang.org/x/sys/unix" "github.com/golang/snappy" ) We usually don't want to introduce a new import group; in most cases, the desired behavior is separating std from third-party packages. With this CL, new imports that don't share prefix with any existing ones will be placed with the first group of third-party imports, if any exist. If no third-party import group exists, a new one will be added. In the case of our example above, this will be the new outcome: import ( "time" "github.com/golang/snappy" "golang.org/x/sys/unix" ) Fixes golang/go#19190. Change-Id: Id4630015c029bd815234a6c8726cb97f4af16f1c Reviewed-on: https://go-review.googlesource.com/37552 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> |
||
---|---|---|
benchmark/parse | ||
blog | ||
cmd | ||
container/intsets | ||
cover | ||
go | ||
godoc | ||
imports | ||
playground | ||
present | ||
refactor | ||
third_party | ||
.gitattributes | ||
.gitignore | ||
AUTHORS | ||
codereview.cfg | ||
CONTRIBUTING.md | ||
CONTRIBUTORS | ||
LICENSE | ||
PATENTS | ||
README |
This subrepository holds the source for various packages and tools that support the Go programming language. Some of the tools, godoc and vet for example, are included in binary Go distributions. Others, including the Go guru and the test coverage tool, can be fetched with "go get". Packages include a type-checker for Go and an implementation of the Static Single Assignment form (SSA) representation for Go programs. To submit changes to this repository, see http://golang.org/doc/contribute.html.