Skip to content

About

Sample Go project used for testing actions

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Test Go Project

This is a sample Go project used for testing GitHub Actions for Go projects.

Features

  • Simple calculator package with basic arithmetic operations
  • Command-line interface
  • Unit tests with testify
  • Go modules support

Usage

# 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

Testing

# Run tests
go test ./...

# Run tests with coverage
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

Building

# Build the binary
go build -o calculator main.go

Linting

The 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.

Dependencies

  • Go 1.26+
  • github.com/stretchr/testify for testing

Fixture properties

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.mod carries a toolchain directive that resolves to a later release than the go directive. go 1.26.0 resolves to 1.26.0, while toolchain go1.26.10 resolves to 1.26.10. Tooling that reads go.mod must prefer toolchain, 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 the go directive resolves to, or dropping the line as redundant, disables that check with no warning. Keep toolchain on 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 as go, too: golangci-lint targets the toolchain release, so a newer line would demand a linter built with that newer Go. See security-workflows#75.

About

Sample Go project used for testing actions

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages