
Go Performance
Focuses on hot path optimizations for Go code with specific, measurable patterns. Covers the common wins like using strconv over fmt for conversions (2x faster), preallocating slice capacity (12x faster in benchmarks), and picking the right string concatenation strategy. Includes a benchmark comparison script and references detailed guides on string optimization and profiling. The advice is grounded in real numbers from Uber and Google style guides, which keeps it honest. Worth noting it explicitly excludes concurrency patterns, so you'll need the separate go-concurrency skill for sync.Pool or goroutine optimization. Best when you're actually profiling and need to know which optimizations matter versus cargo cult performance tweaks.
- skills.sh installs
- 1.3K
- GitHub stars
- 193
- last updated
- Aug 21, 2026
Install
$ npx -y skills add cxuu/golang-skills --skill go-performance --agent claude-codeInstalls into .claude/skills of the current project.
Files
Go Performance Patterns
Resource Routing
scripts/bench-compare.sh- Run when comparing benchmark results, saving baselines, or producing JSON benchmark metadata.references/BENCHMARKS.md- Read when writing benchmarks, using benchstat, or profiling with pprof.references/STRING-OPTIMIZATION.md- Read when optimizing string conversion, concatenation, or byte/string boundaries.
Performance-specific guidelines apply only to the hot path. Don't prematurely optimize—focus these patterns where they matter most.
Prefer strconv over fmt
When converting primitives to/from strings, strconv is faster than fmt:
s := strconv.Itoa(rand.Int()) // ~2x faster than fmt.Sprint()
| Approach | Speed | Allocations |
|---|---|---|
fmt.Sprint | 143 ns/op | 2 allocs/op |
strconv.Itoa | 64.2 ns/op | 1 allocs/op |
Avoid Repeated String-to-Byte Conversions
Convert a fixed string to []byte once outside the loop:
data := []byte("Hello world")
for b.Loop() { // Go 1.24+; use b.N loops only for older Go
w.Write(data) // ~7x faster than []byte("...") each iteration
}
Sponsors
Details
- Repository
- github.com/cxuu/golang-skills
- Categories
- Documentation, Debugging, Go
- First seen
- May 16, 2026
More from cxuu/golang-skills
All 20- Go Context1.3K
- Go Naming1.3K
- Go Defensive1.3K
- Go Packages1.3K
- Go Data Structures1.3K
- Go Functional Options1.3K
- Go Control Flow1.3K
- Go Logging1.1K
- Go Functions1.1K
- Go Generics1.1K
- Go Declarations1.1K
- Go Code Review1.8K
- Go Testing1.4K
- Go Error Handling1.3K
- Go Linting1.3K
- Go Concurrency1.3K
- Go Interfaces1.3K
- Go Documentation1.3K
- Go Style Core1.3K