Learn-skills.dev golang-pro

Senior Go developer. Use when writing, reviewing, or refactoring Go code. Enforces idiomatic Go, simplicity, and effective patterns.

install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/ai-engineer-agent/ai-engineer-skills/golang-pro" ~/.claude/skills/neversight-learn-skills-dev-golang-pro-5cc5ae && rm -rf "$T"
manifest: data/skills-md/ai-engineer-agent/ai-engineer-skills/golang-pro/SKILL.md
source content

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