# Go

> Best practices for Go development including idiomatic patterns, concurrency, and error handling. Use when this capability is needed.

- Skill: `tomevault-io/go-2` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/go-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/go-2/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/go-2

---


# Go Best Practices

## Code Style
- Use gofmt for formatting
- Follow Effective Go guidelines
- Use short variable names in small scopes
- PascalCase for exported, camelCase for unexported

## Error Handling
- Always check errors
- Return errors, don't panic
- Wrap errors with context: fmt.Errorf("context: %w", err)
- Use errors.Is/As for error checking
- Define sentinel errors with errors.New

## Concurrency
- Don't communicate by sharing memory
- Share memory by communicating (channels)
- Use context for cancellation
- sync.WaitGroup for goroutine coordination
- Use select for multiple channel operations

## Patterns
- Accept interfaces, return structs
- Make zero values useful
- Use embedding for composition
- Table-driven tests

## Performance
- Use sync.Pool for object reuse
- Profile with pprof
- Use buffered channels when appropriate
- Avoid premature optimization

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/kprsnt2) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-15 -->

