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:
go get -v golang.org/x/tools/cmd/goimports
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 :
let g:go_fmt_command = "goimports"
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.