This is a sample Go project used for testing GitHub Actions for Go projects.
- Simple calculator package with basic arithmetic operations
- Command-line interface
- Unit tests with testify
- Go modules support
# Run the calculator
go run main.go add 5 3
go run main.go subtract 10 4
go run main.go multiply 6 7
go run main.go divide 15 3# Run tests
go test ./...
# Run tests with coverage
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out# Build the binary
go build -o calculator main.goThe linting setup follows
actions-template.
Install the hooks with prek install. The Go hooks need a Go toolchain
and golangci-lint v2 on
PATH; make dev-setup installs the pinned version. Those hooks are
unavailable on pre-commit.ci, so it skips them. Instead, the Standalone
Linting workflow runs golangci-lint in CI from
go-linting/pre-commit-config.yaml. That workflow pins the file's
SHA-256 digest, so update both together.
- Go 1.26+
- github.com/stretchr/testify for testing
Some of what this repository declares exists for the workflows that scan it rather than for the project itself. Please do not "tidy" these away.
go.modcarries atoolchaindirective that resolves to a later release than thegodirective.go 1.26.0resolves to 1.26.0, whiletoolchain go1.26.10resolves to 1.26.10. Tooling that readsgo.modmust prefertoolchain, and comparing which of the two a consumer ended up with is the sole way to prove that it does. Setting the pin to the release thegodirective resolves to, or dropping the line as redundant, disables that check with no warning. Keeptoolchainon the newest patch of a supported release line: a stale pin misses every later security fix, as Go 1.25.0 missed CVE-2026-111943. Keep it on the same line asgo, too: golangci-lint targets thetoolchainrelease, so a newer line would demand a linter built with that newer Go. See security-workflows#75.