GoLand: File is not `goimports`-ed (goimports)

Had a bit of a head scratcher when I was linting my Go code with golangci-lint. I was getting the following error:

File is not `goimports`-ed (goimports)

After checking for formatting errors (tabs v spaces) and running fmt I found this setting in GoLand which solved the issue (it reorganizes your import section).

All you need to do is set the Sorting type to goimports and you’ll be golden.

How to fix golang "unrecognized import path"

Recently when trying to run go get I ran into the the following error:

ewilson$ go get github.com/nu7hatch/gouuid
package crypto/md5: unrecognized import path "crypto/md5" (import path does not begin with hostname)

After some trial and error (and a few conflicting opinions) I chose to unset my $GOROOT environment variable. Apparently when you compile go (I use brew for most installations) the correct $GOROOT value becomes embedded in the go tool. When you set it manually you can end up conflicting with the correct setting.

You may actually need to run the unset command as once a variable is set it may only be unset by using the unset command.

ewilson$ unset GOROOT

Onward.