cxuu avatar

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-code

Installs 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()
ApproachSpeedAllocations
fmt.Sprint143 ns/op2 allocs/op
strconv.Itoa64.2 ns/op1 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
1neolabhq avatartest-driven-developmentneolabhq/context-engineering-kitUse when implementing any feature or bugfix, before writing implementation code - write the test first, watch it fail, write minimal code to pass; ensures tests1.3Kskills.sh installs
2spritecook avatarspritecook-generate-spritesspritecook/skillsStill-image generation guide for SpriteCook. Use with spritecook-workflow-essentials when generating pixel art or detailed/HD assets, choosing models, and keepi1.3Kskills.sh installs
3cap-go avatarcapacitor-securitycap-go/capgo-skillsComprehensive security guide for Capacitor apps using Capsec scanner. Covers 63+ security rules across secrets, storage, network, authentication, cryptography, 1.3Kskills.sh installs
4github avatarfreecad-scriptsgithub/awesome-copilotExpert skill for writing FreeCAD Python scripts, macros, and automation. Use when asked to create FreeCAD models, parametric objects, Part/Mesh/Sketcher scripts1.3Kskills.sh installs
5alirezarezvani avatarsocial-media-manageralirezarezvani/claude-skillsWhen the user wants to develop social media strategy, plan content calendars, manage community engagement, or grow their social presence across platforms. Also 1.3Kskills.sh installs
6neolabhq avatarsetup-serena-mcpneolabhq/context-engineering-kitGuide for setup Serena MCP server for semantic code retrieval and editing capabilities1.3Kskills.sh installs