toolchains-golang-core
БесплатноБез исполняемых скриптовНе проверенGo 1.22-1.24 core patterns for minimalism, efficiency, code reuse, and performance
от bobmatnyc★ 160 звёзд на GitHubОб этом скилле
Go Core Patterns
Quick Start
- Accept interfaces, return structs — small interfaces at the consumer site
- Pre-allocate slices/maps with
make([]T, 0, n)/make(map[K]V, n) - Wrap errors with
%w; check witherrors.Is/errors.As - Always run
go test -race ./...in CI - Profile with
go tool pprofbefore optimizing anything
Minimalism Patterns
- Accept interfaces, return structs — narrow interface params improve testability; concrete return types preserve extensibility
- Define interfaces at the consumer — the calling package defines what it needs; avoid coupling interface to implementation
- Keep interfaces small — 1-2 methods; compose with embedding:
type ReadWriter interface { Reader; Writer } - Functional options for constructors —
func WithTimeout(d time.Duration) Optionreturns a closure; keepsNew*signatures stable - Unexported option fields — export
With*functions, keep struct fields private; one construction path, predictable outcome - Constructor naming —
NewServer(opts ...Option) *Server; the injection point for interface-typed dependencies - Avoid
init()side effects — prefer explicit initialization inmain()or constructors;init()hides execution order
Efficiency Patterns
- Pre-allocate slices —
make([]T, 0, n)eliminates grow-copy cycles; reduces GC pressure ~30% - Pre-allocate maps —
make(map[K]V, n)avoids rehashing; over-estimate rather than under-estimate strings.Builderover+— internal[]bytebuffer; callb.Grow(n)to pre-size before writingsync.Poolfor short-lived objects — reuse buffers, byte slices, response structs; always reset before returning to pool- Avoid
any/interface{}in hot paths — boxing causes heap allocation and dynamic dispatch; use concrete types or generics strconvoverfmt.Sprintfin hot paths —fmtarguments escape to heap;strconv.Itoa,AppendIntstay on stack- Value receivers for small immutable types — no pointer indirection; both
Tand*Tsatisfy value-receiver methods - Pointer receivers for large structs or mutation — avoids copying; be consistent within a type (all pointer or all value)
- Return values not pointers for small types — keeps allocation on stack; reduces GC pressure in tight loops
- Move loop-invariant work outside loops — constant calculations inside hot loops multiply with iteration count
Code Reuse
- Generics:
anyfor store/pass only — no operations needed; suitable for containers likeStack[T any] - Generics:
comparablefor equality — required for map keys, sets,Contains();anydoes not satisfycomparable - Generics:
constraints.Orderedfor comparisons — covers int, float, string; needed for sort, min, max helpers - Generics: prefer function params over method constraints — pass
cmp func(T, T) intrather than requiring aComparemethod - Generics: start concrete, genericize on duplication — add type params only when the same logic repeats for multiple types
- Embed structs for implementation reuse — promoted fields and methods; override selectively; avoid deep embedding chains
- Domain packages over layer packages —
internal/user/,internal/order/notinternal/handlers/,internal/services/ - No catch-all
utilspackages — every package has a focused purpose; move helpers into the domain that owns them
Modern Go (1.22-1.23)
- Range over integers (1.22) —
for i := range 10replacesfor i := 0; i < 10; i++ - Loop variable fix (1.22) — each iteration creates new variables; closure capture bugs eliminated
- Enhanced
ServeMux(1.22) —"GET /items/{id}"registers method + wildcard;r.PathValue("id")extracts segments - Wildcard catch-all (1.22) —
"/files/{path...}"matches remaining path; must appear at end of pattern Request.Pattern(1.23) — matched pattern available on the request for logging and observability- Range over function iterators (1.23) —
func(func(K, V) bool)as range expressions; stable in 1.23 iterpackage (1.23) —iter.Seq[V]anditer.Seq2[K, V]standard types; foundation for custom iteratorsslices/mapsiterators (1.23) —slices.All,slices.Collect;maps.Keys,maps.Values,maps.Collectuniquepackage (1.23) — canonical interning of comparable values; deduplication and memory savingsslogfor structured logging — JSON handler in prod, text in dev;slog.SetDefaultbridges legacylog.Printfcalls- Contextual log fields — pass
request_id,user_id,trace_idviaslog.With()to correlate log lines LogValuerfor sensitive types — redact PII; skips expensive computation when log level is disabled
Modern Go (1.24)
tooldirective ingo.mod(1.24) — track executable dependencies natively;go get -tooladds them,go tool <name>runs them. Replaces the old blank
Установить toolchains-golang-core в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл toolchains-golang-core?
Go 1.22-1.24 core patterns for minimalism, efficiency, code reuse, and performance
Как установить скилл toolchains-golang-core?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл toolchains-golang-core запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic