Build and Run

  • go run . - build (if necessary) a temporary executable and run the project in the CWD
  • go build - build a runnable executable in the CWD



  • go mod init mymod - create a Go module in the CWD, named mymod
  • Use a module in a code import statement, then run go get . to pull it into go.mod


  • go fmt - format code in the Go style
  • goimports -l -w . - clean up imports for go files in CWD
    • Install with go install golang.org/x/tools/cmd/goimports@latest

Linting and Vetting

  • go install golang.org/x/lint/golint@latest - install the linter.
  • golint ./... - lint project

Vet can be used to find logical errors.

  • go vet ./...

All-In-One - golangci-lint

Source: https://github.com/golangci/golangci-lint

  • Mac: brew install golangci-lint
  • golangci-lint run - run the suite


  • go install github.com/rakyll/hey@latest - Download, build and install a given package.