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.mdsource 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
— non-negotiable formattinggoimports - 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
,IDURL - Keep functions short — if it scrolls, split it
Project Structure
- Follow the standard Go project layout
for binaries,cmd/<app>/main.go
for private packagesinternal/
only for truly reusable library code (preferpkg/
)internal/- One package per directory, package name matches directory name
at repository rootgo.mod
Patterns
- Accept interfaces, return structs
- Use
as the first parameter for functions that do I/Ocontext.Context - Use
anderrors.Is()
for error comparison (noterrors.As()
)== - Use
for error wrappingfmt.Errorf("...: %w", err) - Use table-driven tests
- Use
for lazy initializationsync.Once - Use channels for communication, mutexes for state
- Use
(Go 1.21+) for structured loggingslog
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
for package-level error constantserrors.New() - Use custom error types with
method for rich errorsError() - Wrap errors with context:
fmt.Errorf("open config: %w", err)
Testing
- Test files:
in the same package<file>_test.go - Use
, table-driven tests, subtests withtesting.Tt.Run() - Use
ortestify/assert
for assertionstestify/require - Use
for HTTP testinghttptest.NewServer - Use
for independent testst.Parallel() - Benchmarks in
with_test.gofunc Benchmark*(b *testing.B)
Concurrency
- Don't start goroutines without a plan to stop them
- Use
for concurrent operations with error handlingerrgroup.Group - Use
for goroutine lifecyclecontext.WithCancel - Never use
for synchronizationtime.Sleep