Go – About goimport tool .

A Go developer know the code must be formatted with the standard gofmt tool.
While gofmt attracts much attention, goimport is overlooked despite often being more useful.
Basically, goimport does everything that gofmt do.
First, you need to install into go using:

This will auto import Go packages using goimports tool.
While correcting, goimports removes unused imports and adds missing ones.
Additionally, it groups and corrects imported packages.
You can use with vim and atom editors.
To setup vim editor to autorun goimports on save using vim-go, use this :

If you want to use the atom editor then you need to install the atom package named go-imports from abiosoft.
Use command palette cmd-shift-p, search for Go Imports: Process or using keybinding ctrl-shift-i.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.