Skip to content

Guidelines for Go

diligentis edited this page Oct 5, 2022 · 2 revisions

Version

Each repository can maintain its own version of the Go toolchain. Whatever is specified in the root go.mod file is considered canonical for that repository.

Tooling

Formatting

Go code should be formatted via gofumpt, a slightly more opinionated variant of gofmt. This can be automated for pre-commit hooks via golangci-lint.

Linting

Linting should be handled via golangci-lint.

The list of linters that should be enabled is being compiled.

Testing

Testing should be performed by the built in go test command. -race detection should be utilized and code coverage via -covermode=atomic.

Reporting via codecov.io with a badge on the README.md is recommended.

Packaging

Go services should be packaged via Docker utilizing multi-stage builds and distroless containers.

Documentation

Documenting go code should follow standard godoc conventions.

Continuous Integration

Continuous Integration is performed with GitHub Actions.

CI should:

  • Ensure code builds cleanly
  • All unit tests pass
  • All integration tests pass
  • Check for race conditions
  • Lint cleanly
  • Code is formatted correctly
  • All generated files are up to date

See Also