
Go Best Practices
This teaches you how to write idiomatic Go using types to prevent bugs at compile time. You'll learn custom types for domain primitives like UserID, functional options for flexible constructors, and when to use interfaces versus structs. The error handling section is minimal but covers the critical bit about wrapping with %w to preserve error chains. It also pushes structured logging with slog instead of printf debugging. The examples are clean and you can copy them directly. If you're coming from dynamic languages or just want to stop passing the wrong ID type to functions, this will save you from entire categories of runtime errors.
- skills.sh installs
- 272
- GitHub stars
- 48
- last updated
- Jun 3, 2026
Install
$ npx -y skills add 0xbigboss/claude-code --skill go-best-practices --agent claude-codeInstalls into .claude/skills of the current project.
Files
Go Best Practices
Follows type-first, functional, and error handling patterns from CLAUDE.md. This skill covers language-specific idioms only.
Make Illegal States Unrepresentable
Use Go's type system to prevent invalid states at compile time.
Custom types for domain primitives:
// Distinct types prevent mixing up IDs
type UserID string
type OrderID string
func GetUser(id UserID) (*User, error) {
// Compiler prevents passing OrderID here
}
// Methods attach behavior to the type
func (id UserID) String() string {
return string(id)
}
Interfaces for behavior contracts:
// Define what you need, not what you have
type UserRepository interface {
GetByID(ctx context.Context, id UserID) (*User, error)
Save(ctx context.Context, user *User) error
}
// Accept interfaces, return structs
func ProcessInput(r io.Reader) ([]byte, error) {
return io.ReadAll(r)
}
Enums with iota and exhaustive switch:
type Status int
const (
StatusActive Status = iota + 1
StatusInactive
StatusPending
)
Sponsors
Details
- Repository
- github.com/0xbigboss/claude-code
- Category
- Go
- First seen
- Jun 3, 2026
More from 0xbigboss/claude-code
All 22- Playwright Best Practices266
- Axe Ios Simulator239
- Electrobun Best Practices209
- Tilt196
- Orbstack Best Practices180
- Canton Network Repos157
- Ios Device Screenshot155
- Atlas Best Practices154
- Git Best Practices149
- Git Rebase Sync146
- Testing Best Practices135
- E2e126
- Extract Transcripts122
- React Best Practices3K
- Typescript Best Practices2.9K
- Python Best Practices1.8K
- Web Fetch929
- Zig Best Practices388
- Nix Best Practices359
- Tamagui Best Practices290
- Openai Image Gen288