go-performance

Optimize Go hot-path code with strconv and preallocated containers.

Updated Feb 28, 2026
One-click install
npx skills add https://github.com/phant-app/phant --skill go-performance-phant-app
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-performance
Source: https://github.com/phant-app/phant/tree/main/.agents/skills/go-performance
Command: npx skills add https://github.com/phant-app/phant --skill go-performance-phant-app

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go performance patterns help developers optimize hot-path code by providing proven techniques for faster string handling, safer conversions, and efficient memory usage.

Core Features & Use Cases

  • Prefer strconv over fmt for numeric conversions to reduce allocations and improve speed.
  • Avoid repeated string-to-byte conversions by reusing precomputed byte slices.
  • Prefer specifying container capacity to minimize dynamic allocations.
  • Pass values instead of pointers for small types to reduce indirection.
  • Use these patterns to improve throughput in services handling high request volumes or in data-intensive pipelines.

Quick Start

Audit your hot-path code and apply the patterns by replacing fmt.Sprint with strconv, preallocating containers, and avoiding repetitive conversions.

Frequently Asked Questions about go-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize Go performance in high-volume request hot paths?

Refactor hot-path Go code by applying Uber Go Style Guide patterns: use strconv for numeric conversions, preallocate container capacities, and pass small values instead of pointers to reduce memory allocations and indirection.

Why does using strconv over fmt improve Go memory management?

Using strconv over fmt improves Go memory management because strconv avoids reflection and intermediate allocations during numeric conversions, directly reducing garbage collection pressure in performance-critical paths.

What is the best way to avoid repeated string-to-byte conversions in Go?

The best way to avoid repeated string-to-byte conversions in Go is to precompute the byte slice once and reuse it across calls, preventing redundant allocations that degrade hot-path performance.

Does passing values instead of pointers optimize Go performance for small types?

Passing values instead of pointers optimizes Go performance for small types by eliminating pointer indirection and reducing escape analysis overhead, thereby lowering garbage collection pressure in hot-path code.

When do I need to specify container capacity for Go memory allocation optimization?

You need to specify container capacity for Go memory allocation optimization when dynamically appending to slices or maps in data-intensive pipelines, as preallocation prevents repeated resizing and minimizes dynamic allocations.