| name | go-helper |
| description | Go development with modules, testing, linting, and common patterns
When user works with .go files, mentions Go, golang, go modules, go test, or encounters Go compiler errors
|
Go Helper Agent
What's New in Go (2023-2026)
- Go 1.26 (Feb 2026):
new() accepts any expression (not just type names), Green Tea GC enabled by default (10-40% lower GC overhead), crypto/hpke package (HPKE RFC 9180), experimental simd/archsimd package (GOEXPERIMENT=simd), ~30% lower cgo call overhead, cmd/doc removed (use go doc), pprof opens flame graph by default
- Go 1.25 (Aug 2025): Experimental Green Tea GC (10-40% lower GC overhead in heavy workloads),
encoding/json/v2 package with custom marshalers/unmarshalers, testing/synctest now stable, runtime/trace.FlightRecorder ring buffer API, DWARF v5 debug info (smaller binaries), cgroup CPU bandwidth-aware GOMAXPROCS on Linux
- Go 1.24 (Feb 2025): Generic type aliases fully supported,
tool directives in go.mod for executable dependencies, SwissTable map implementation (~30% faster large map access), runtime.AddCleanup replaces SetFinalizer, os.Root for directory-scoped filesystem ops, FIPS 140-3 compliance mechanisms, go:wasmexport directive, experimental testing/synctest package
- Go 1.23 (Aug 2024): Range-over-function iterators (
range accepts iterator functions), new iter package, new unique package for value interning, slices/maps iterator functions (All, Values, Collect), unbuffered timer channels (no stale values after Stop/Reset), go vet checks for too-new symbols, go env -changed, go mod tidy -diff
- Go 1.22 (Feb 2024): Per-iteration for-loop variables (no more accidental sharing),
range over integers, net/http.ServeMux supports methods and wildcards (GET /task/{id}/), math/rand/v2, slices.Concat, PGO devirtualization (2-14% improvement)
- Go 1.21 (Aug 2023): Built-in
min, max, clear functions, log/slog structured logging, slices/maps/cmp packages, panic(nil) now causes *runtime.PanicNilError, WASI Preview 1 support, PGO 2-7% improvements, GC tail latency up to 40% lower
- Current stable: 1.26.x (Feb 2026)
Overview
This skill covers Go development using the go toolchain, testing (go test, table-driven tests, fuzzing, benchmarks), linting (go vet, golangci-lint), formatting (gofmt, goimports), debugging (delve, pprof), and the module system. It includes error handling, interfaces, generics, concurrency, context, iterators, and struct embedding patterns.
CLI Commands
Auto-Approved Safe Commands
go vet ./...
gofmt -l .
goimports -l .
go build ./...
go test ./...
go list -m all
go mod tidy
go mod download
go doc fmt.Println
go env
go tool
Build and Run
go build ./...
go build ./cmd/myapp
go build -o myapp ./cmd/myapp
go build -race ./cmd/myapp
go build -tags "integration,debug" ./...
go build -ldflags "-X main.version=1.0.0 -X main.commit=$(git rev-parse HEAD)" ./cmd/myapp
go build -ldflags "-s -w" -trimpath ./cmd/myapp
go run ./cmd/myapp
go run ./cmd/myapp -- --flag value
go install ./cmd/myapp
GOOS=linux GOARCH=amd64 go build -o myapp-linux ./cmd/myapp
GOOS=darwin GOARCH=arm64 go build -o myapp-darwin ./cmd/myapp
GOOS=windows GOARCH=amd64 go build -o myapp.exe ./cmd/myapp
go tool dist list
Testing
go test ./...
go test -v ./...
go test -run TestMyFunction ./pkg/mypackage
go test -race ./...
go test -cover ./...
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
go test -bench=. ./...
go test -bench=BenchmarkMyFunc -benchmem ./...
go test -fuzz=FuzzMyFunc -fuzztime=30s ./...
go test -timeout 60s ./...
go test -short ./...
go test -v -count=1 ./...
go test -list '.*' ./...
go test -parallel 1 ./...
Linting and Formatting
gofmt -w .
goimports -w .
gofmt -l .
goimports -l .
go vet ./...
golangci-lint run
golangci-lint run ./...
golangci-lint run --fix
golangci-lint run --enable errcheck,staticcheck,gosec
Modules
go mod init github.com/user/project
go get github.com/pkg/errors
go get github.com/pkg/errors@v0.9.1
go get github.com/pkg/errors@latest
go get -u ./...
go get -u github.com/pkg/errors
go mod tidy
go mod vendor
go mod graph
go mod verify
go mod why github.com/pkg/errors
go mod edit -require github.com/pkg/errors@v0.9.1
go mod edit -replace github.com/old/pkg=github.com/new/pkg@v1.0.0
go mod edit -dropreplace github.com/old/pkg
go work init ./module-a ./module-b
go work use ./module-c
go work sync
Tool Dependencies (Go 1.24+)
go get -tool golang.org/x/tools/cmd/stringer
go get -tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
go tool stringer -type=MyType
go tool golangci-lint run
go mod edit -json | jq '.Tool'
Essential Patterns Quick Reference
Error Handling
func readConfig(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("reading config %s: %w", path, err)
}
var cfg Config
if err := json.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("parsing config: %w", err)
}
return &cfg, nil
}
var ErrNotFound = errors.New("not found")
var ErrPermission = errors.New("permission denied")
if errors.Is(err, ErrNotFound) { }
var pathErr *os.PathError
if errors.As(err, &pathErr) { }
Interfaces
type Reader interface {
Read(p []byte) (n int, err error)
}
type Writer interface {
Write(p []byte) (n int, err error)
}
type ReadWriter interface {
Reader
Writer
}
func Process(r io.Reader) (*Result, error) {
data, err := io.ReadAll(r)
if err != nil {
return nil, err
}
return &Result{Data: data}, nil
}
Generics (Go 1.18+)
func Map[T, U any](s []T, f func(T) U) []U {
result := make([]U, len(s))
for i, v := range s {
result[i] = f(v)
}
return result
}
type Number interface {
~int | ~int32 | ~int64 | ~float32 | ~float64
}
func Sum[T Number](nums []T) T {
var total T
for _, n := range nums {
total += n
}
return total
}
Iterators (Go 1.23+)
func All[T any](s []T) iter.Seq[T] {
return func(yield func(T) bool) {
for _, v := range s {
if !yield(v) {
return
}
}
}
}
func Entries[K comparable, V any](m map[K]V) iter.Seq2[K, V] {
return func(yield func(K, V) bool) {
for k, v := range m {
if !yield(k, v) {
return
}
}
}
}
for v := range All(mySlice) {
fmt.Println(v)
}
Concurrency
var wg sync.WaitGroup
for _, url := range urls {
wg.Add(1)
go func() {
defer wg.Done()
fetch(url)
}()
}
wg.Wait()
g, ctx := errgroup.WithContext(ctx)
for _, url := range urls {
g.Go(func() error {
return fetch(ctx, url)
})
}
if err := g.Wait(); err != nil {
return err
}
Struct Embedding
type Base struct {
ID string
}
func (b *Base) Identify() string { return b.ID }
type Server struct {
Base
Host string
Port int
}
s := Server{Base: Base{ID: "srv-1"}, Host: "localhost", Port: 8080}
s.Identify()
go.mod Quick Reference
module github.com/user/project
go 1.24
tool (
golang.org/x/tools/cmd/stringer
github.com/golangci/golangci-lint/v2/cmd/golangci-lint
)
require (
github.com/go-chi/chi/v5 v5.1.0
github.com/jackc/pgx/v5 v5.7.0
go.uber.org/zap v1.27.0
)
require (
golang.org/x/sys v0.25.0
)
replace github.com/my/lib => ../my-lib
When to Ask for Help
Ask the user for clarification when:
- Error handling strategy needs deciding (sentinel vs custom types vs wrapping)
- Concurrency pattern choice is unclear (channels vs mutex vs errgroup)
- Interface design decisions are needed
- Module structure or workspace layout is unclear
- Performance vs readability tradeoffs exist
- Context propagation or cancellation patterns are complex
See references/ for detailed guides:
patterns.md - Error handling, interfaces, generics, concurrency, context, iterators, struct embedding, testing patterns
modules-tooling.md - Go modules, workspaces, dependency management, golangci-lint, go vet, gopls, build tags, cross-compilation, popular packages
testing-debugging.md - go test, table-driven tests, benchmarks, fuzzing, testify, delve debugger, profiling with pprof, race detector