1
0
mirror of https://github.com/golang/go synced 2024-11-18 23:54:41 -07:00
go/internal/imports
Suzy Mueller ea4142463b internal/imports: merge import declarations
When an import is added to the ast, the import declarations are merged
together into the first import declaration. Since this is a part of
the formatting functionality of goimports, do this during formatting
regardless.

The merging pass was added to astutil.AddNamedImport in order to address
issue golang/go#14075. This joined imports from other blocks into the first
import declaration, so that a single block of imports isn't split across
multiple blocks.

This functionality is more of a formatting change than a fix imports
change, in line with sorting the imports, which occurs even when
FormatOnly. The formatting was only applied when an import was added
(not renamed or deleted). This change makes formatting by goimports
more consistent across runs and is not dependent on the exact fixes
that need to be applied.

Change-Id: Icb90bf694ff35e2d6405a3d477cf82fcd3e697e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/189941
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2019-08-14 23:54:02 +00:00
..
testdata/mod imports: rename to internal/imports 2019-05-20 21:49:35 +00:00
fix_test.go internal/imports: merge import declarations 2019-08-14 23:54:02 +00:00
fix.go internal/imports: use the resolver to load exports 2019-08-14 23:51:36 +00:00
imports_test.go internal/imports: test exported functions with nil args 2019-08-14 23:42:26 +00:00
imports.go internal/imports: merge import declarations 2019-08-14 23:54:02 +00:00
mkindex.go imports: rename to internal/imports 2019-05-20 21:49:35 +00:00
mkstdlib.go imports: rename to internal/imports 2019-05-20 21:49:35 +00:00
mod_112_test.go imports: rename to internal/imports 2019-05-20 21:49:35 +00:00
mod_test.go internal/imports: save scanned module cache results 2019-07-18 20:03:17 +00:00
mod.go internal/imports: use the resolver to load exports 2019-08-14 23:51:36 +00:00
proxy_112_test.go imports: rename to internal/imports 2019-05-20 21:49:35 +00:00
proxy_113_test.go imports: rename to internal/imports 2019-05-20 21:49:35 +00:00
sortimports.go internal/imports: merge import declarations 2019-08-14 23:54:02 +00:00
zstdlib.go imports: rename to internal/imports 2019-05-20 21:49:35 +00:00