goimports
Updates Go import lines, adding missing ones and removing unreferenced ones. More information: https://godoc.org/golang.org/x/tools/cmd/goimports.
-
Display the completed import source file:
goimports {{path/to/file}}.go
-
Write the result back to the source file instead of
stdout
:
goimports -w {{path/to/file}}.go
-
Display diffs and write the result back to the source file:
goimports -w -d {{path/to/file}}.go
-
Set the import prefix string after 3rd-party packages (comma-separated list):
goimports -local {{path/to/package}} {{path/to/file}}.go
License and Disclaimer
The content on this page is copyright © 2014—present the tldr-pages team and contributors.This page is used with permission under Creative Commons Attribution 4.0 International License.
While we do attempt to make sure content is accurate, there isn't a warranty of any kind.