brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
go-ciContinuous integration for Go projects: GitHub Actions pipelines, caching, golangci-lint setup, test/coverage gates, vulnerability scanning, build matrices, and Makefile targets. Use when: "set up CI", "GitHub Actions for Go", "add lint to the pipeline", "CI is slow", "coverage gate", "build matrix", "write a Makefile", "run govulncheck in CI". Not for: com…
Independent GitHub snapshot · Automated classification · Original documentation governs
A Go pipeline has exactly four gates: build, vet/lint, test with race detector, vulnerability scan. Everything else is optimization.
name: ci
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod # single source of truth
cache: true # caches module + build cache
- run: go build ./...
- run: go vet ./...
- run: go test -race -shuffle=on -coverprofile=coverage.out ./...
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v6
with:
version: latest
vuln:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
Key decisions baked in:
go-version-file: go.mod — never hardcode the Go version in two places.cache: true on setup-go handles module and build caches; do not add
manual actions/cache steps for Go on top of it.-race -shuffle=on — races and order-dependent tests fail in CI, not
production.permissions: contents: read — least privilege by default.Commit a .golangci.yml; an unconfigured linter is noise:
linters:
enable:
- errcheck # unchecked errors
- govet
- staticcheck
- errorlint # %w misuse, == on errors
- gosec # security patterns
- revive # style, replaces golint
- misspell
issues:
exclude-rules:
- path: _test\.go
linters: [gosec] # test code may use weak randomness etc.
Start from this small set and add linters deliberately. Enabling
everything produces hundreds of findings nobody triages. nolint
directives require a reason: //nolint:gosec // G404: jitter, not crypto.
strategy:
matrix:
go: ['1.23', '1.24'] # only versions you support
os: [ubuntu-latest, macos-latest, windows-latest]
Libraries: test the two newest Go versions (the Go team supports two).
Services deployed on Linux: skip the OS matrix — it doubles cost for
platforms you never ship. Cross-compilation is cheaper than emulation:
GOOS=windows go build ./... catches most portability breaks.
- run: go test -race -coverprofile=coverage.out ./...
- name: enforce coverage floor
run: |
total=$(go tool cover -func=coverage.out | awk '/^total:/ {sub(/%/,"",$3); print $3}')
echo "coverage: ${total}%"
awk -v t="$total" 'BEGIN { exit (t < 70.0) }'
Gate on a floor that ratchets up, not a target that gets gamed. Exclude
generated code via //go:generated files' build tags or grep filters,
not by lowering the floor.
CI must run what developers run. One definition, two callers:
.PHONY: build lint test vuln ci
build:
go build ./...
lint:
golangci-lint run
test:
go test -race -shuffle=on -coverprofile=coverage.out ./...
vuln:
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
ci: build lint test vuln
If CI does anything make ci doesn't, developers discover failures
only after pushing. Keep them identical.
go test ./... already parallelizes across packages; don't shard a
small repo.go test -tags=integration ./....go.sum is the
cache key input (setup-go does this) and that jobs don't mutate it.go-version-file), not duplicatedpermissions: contents: read set at workflow level-race -shuffle=on.golangci.yml committed with a curated linter setnolint carries a linter name and a reasonmake ci reproduces the pipeline locally, byte-for-byte