| name | golang-ci-docs |
| description | Design, maintain, and review Go continuous integration workflows (GitHub Actions, matrix testing, SHA pinning) and comprehensive code documentation (godoc, executable examples, ADRs). |
Go CI, Automation & Documentation Guide
Reliable Go software requires automated quality gates in CI and clear, standard documentation that integrates with the Go toolchain and pkgsite.
1. Continuous Integration & Workflow Best Practices
Secure GitHub Actions Workflow
- Pin Actions to Immutable Commit SHAs: Prevent supply-chain poisoning by referencing full commit SHAs rather than mutable tags.
- Enable Dependency & Build Caching: Use native
actions/setup-go caching for faster CI cycles.
- Matrix Testing: Test across OS platforms and Go minor versions when building portable software.
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Set up Go
uses: actions/setup-go@3041df56c16aff9da48da3f4cbe55ab85bc31221
with:
go-version: '1.24'
check-latest: true
cache: true
- name: Verify Dependencies
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Run Linters
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8
- name: Vulnerability Scan
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
- name: Run Tests with Race Detector
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
2. Go Documentation Standards & Godoc
Package Doc Comments
Every package should have a package comment immediately preceding package name (in doc.go or the primary package file):
package lipapi
Exported Identifier Comments
Every exported function, type, constant, and variable must start with its own name and form a complete sentence:
type StreamCollector struct { ... }
func NewCollector() *StreamCollector { ... }
func CreateCollector() *StreamCollector { ... }
Executable Testable Examples
Add examples in _test.go files that serve as verified documentation and run as part of go test:
func ExampleStreamCollector_Collect() {
collector := NewCollector()
collector.AddEvent(Event{Type: "chunk", Content: "Hello"})
collector.AddEvent(Event{Type: "chunk", Content: " World"})
resp := collector.Finalize()
fmt.Println(resp.Content)
}
3. Architecture Decision Records (ADRs)
Document significant architectural choices under docs/adr/ using a standard format:
- Title & Status: Context, Proposed, Accepted, Superceded.
- Context: The problem, constraints, and driving factors.
- Decision: The chosen technical architecture and boundary design.
- Consequences: Trade-offs, benefits, and maintenance considerations.