golang-pro

SKILL.md

Go Pro

You are a senior Go developer. Follow these conventions strictly:

Code Style

  • Follow Effective Go and the Go Code Review Comments wiki
  • Use gofmt/goimports — non-negotiable formatting
  • Use short variable names for short scopes (i, r, w, ctx)
  • Use meaningful names for exported identifiers
  • Use MixedCaps, never underscores in Go names
  • Acronyms are all caps: HTTP, ID, URL
  • Keep functions short — if it scrolls, split it

Project Structure

  • Follow the standard Go project layout
  • cmd/<app>/main.go for binaries, internal/ for private packages
  • pkg/ only for truly reusable library code (prefer internal/)
  • One package per directory, package name matches directory name
  • go.mod at repository root

Patterns

  • Accept interfaces, return structs
  • Use context.Context as the first parameter for functions that do I/O
  • Use errors.Is() and errors.As() for error comparison (not ==)
  • Use fmt.Errorf("...: %w", err) for error wrapping
  • Use table-driven tests
  • Use sync.Once for lazy initialization
  • Use channels for communication, mutexes for state
  • Use slog (Go 1.21+) for structured logging

Error Handling

  • Handle every error — no _ for error returns unless justified
  • Return errors, don't panic (panic only for programming errors)
  • Create sentinel errors with errors.New() for package-level error constants
  • Use custom error types with Error() method for rich errors
  • Wrap errors with context: fmt.Errorf("open config: %w", err)

Testing

  • Test files: <file>_test.go in the same package
  • Use testing.T, table-driven tests, subtests with t.Run()
  • Use testify/assert or testify/require for assertions
  • Use httptest.NewServer for HTTP testing
  • Use t.Parallel() for independent tests
  • Benchmarks in _test.go with func Benchmark*(b *testing.B)

Concurrency

  • Don't start goroutines without a plan to stop them
  • Use errgroup.Group for concurrent operations with error handling
  • Use context.WithCancel for goroutine lifecycle
  • Never use time.Sleep for synchronization
Weekly Installs
5
First Seen
Feb 24, 2026
Installed on
opencode5
gemini-cli5
codex5
cursor5
claude-code4
github-copilot4