Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 2.15 KB

File metadata and controls

61 lines (44 loc) · 2.15 KB

Agents

Before committing

Run all CI validations locally before committing changes:

make validate-all

This runs the same checks as CI:

  1. go mod tidy — ensures go.mod/go.sum are clean
  2. Lint — runs golangci-lint (see .golangci.yml for configuration)
  3. Tests — runs all unit tests with race detection (go test -race ./...)
  4. ShellCheck — validates all shell scripts

If any step fails, fix the issue and re-run before committing.

Prerequisites

  • Go 1.25.6+
  • golangci-lint v2.7.2+Install instructions
  • ShellCheckbrew install shellcheck (macOS) or apt-get install shellcheck (Linux)

Testing

When adding a new Go package that contains tests, include a testmain_test.go file in the package directory to enable automatic goroutine leak detection via go.uber.org/goleak. Match the package declaration to the existing test files in that directory (use the external package foo_test form if that is what the other test files use).

package <pkg> // or <pkg>_test — match the existing test files

import (
	"testing"

	"go.uber.org/goleak"
)

// TestMain runs goleak after the test suite to detect goroutine leaks.
func TestMain(m *testing.M) {
	goleak.VerifyTestMain(m)
}

If the package already has a TestMain that does non-trivial setup (e.g. starting a server), integrate goleak manually using the setup → m.Run() → teardown → goleak.Findos.Exit pattern instead of calling goleak.VerifyTestMain.

Project documentation