1. 5
  1.  

  2. 4

    Better yet, use an editor that integrates gofmt, goimports, and go vet. It’s kind of magical: errors and warnings highlighted automatically, packages imported (or unimported) as needed, formatting is always correct.

      1. 1

        gometalinter delivers further magic, from third party static checks. A couple key ones are errcheck (yell about implicitly discarded errors) and ineffasign (catch unused assignments to existing vars, not only unused vars), but others (gosimple, unconvert, deadcode) find spots in your code where you did something redundant or just odd-looking, which sometimes point to editing or thinking errors. (You probably don’t want to use all of the linters all the time; you can pick your list with command-line options.)

        For Go beginners that aren’t already using vim/emacs (for which there’s vim-go/go-mode), I can recommend VS Code’s Go extension, which supports fmt, linting, and completion, and a bunch of other stuff. People vary in how much hand-holding they want once they’re familiar with Go, but an environment offering lots of info like this seems really helpful for getting started.