go-core-idioms

Guides writing and reviewing idiomatic sequential Go covering errors, slog logging, generics, and interfaces.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill go-core-idioms-fusengine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: go-core-idioms
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/go-expert/skills/go-core-idioms
Command: npx skills add https://github.com/fusengine/kimi-code --skill go-core-idioms-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go code written by developers or generated by AI often violates core language idioms — swallowed errors, broken error chains, misplaced interfaces, and unstructured logging. This Skill enforces idiomatic sequential Go 1.26 patterns so code reviews and implementations follow community-accepted conventions. ## Core Features & Use Cases - Error handling patterns: Explicit if err != nil checks, %w wrapping, sentinel and typed errors, errors.Join aggregation, and the Go 1.26 generic errors.AsType inspection. - Structured logging with slog: Handler selection (JSON vs Text), attributes, groups, LogValuer redaction, dynamic levels, and allocation-free LogAttrs hot paths. - Generics and Go 1.26 features: Type parameters, self-referential constraints, new(expr) initialization, and go fix modernizers. - Interface and style guidance: Consumer-side interfaces, value-vs-pointer receivers, naming conventions, and LLM anti-pattern detection. - Use Case: When reviewing a Go service that discards errors with _ = err and defines an IUserRepository interface next to its only implementation, use this Skill to rewrite the error strategy with %w wrapping and move the interface to the consumer package. ## Quick Start Ask the agent to review or write sequential Go code following idiomatic error handling, slog logging, and interface conventions, for example: review my user package for idiomatic Go error handling and logging.

Frequently Asked Questions about go-core-idioms

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

FAQPage Schema
How do I handle errors idiomatically in Go?▼

Check errors explicitly with `if err != nil` and wrap them using `fmt.Errorf` with `%w` to preserve the chain for `errors.Is` and `errors.AsType`. Never discard errors with `_ = err`, and add context the caller does not already have.

How do I set up structured logging in Go with slog?▼

Create a logger with `slog.New` using `slog.NewJSONHandler` for production or `slog.NewTextHandler` for development, then call `slog.SetDefault`. Pass key/value attributes instead of formatted strings, and use `LogAttrs` on hot paths to avoid allocation.

What is the difference between errors.As and errors.AsType in Go?▼

errors.AsType is the generic, type-safe replacement for errors.As introduced in Go 1.26. It returns the typed error and a boolean directly, removing the out-parameter boilerplate, and is faster than errors.As.

When should I use pointer receivers versus value receivers in Go?▼

Use value receivers by default for small, immutable types. Choose pointer receivers only when the method mutates the receiver, the struct is large enough that copying is costly, or the type already has pointer-receiver methods for consistency.

Does this Skill cover goroutines and channels?▼

No, concurrency topics such as goroutines, channels, errgroup, and context cancellation are explicitly out of scope. Those are handled by the separate go-concurrency skill; this one covers only sequential Go idioms.

Where should interfaces be defined in a Go package?▼

Define interfaces where they are consumed, listing only the methods that consumer needs, and return concrete structs from constructors. Avoid declaring an interface next to its single implementation just for testing.