Go – About goimport tool .

By | 28/12/2017

A Go developer know the code must be formatted with standard gofmt tool.
While gofmt attracks 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 used with vim and atom editors.
To setup vim editor to auto run 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.