0xbigboss avatar

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

Installs 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

Recommended

More Go
1encoredev avatarencore-go-infrastructureencoredev/skillsDeclare infrastructure with Encore Go.211skills.sh installs
2personamanagmentlayer avatargo-expertpersonamanagmentlayer/pclExpert-level Go development with Go 1.22+ features, concurrency, standard library, and production-grade best practices188skills.sh installs
3jetbrains avataruse-modern-gojetbrains/go-modern-guidelinesApply modern Go syntax guidelines based on project's Go version. Use when user ask for modern Go code guidelines.2.9Kskills.sh installs
4mindrally avatargomindrally/skillsExpert in Go/Golang development with focus on APIs, microservices, and clean architecture784skills.sh installs
5coreyhaines31 avatarlaunchcoreyhaines31/marketingskillsWhen the user wants to plan a product launch, feature announcement, or release strategy. Also use when the user mentions 'launch,' 'Product Hunt,' 'feature rele86.3Kskills.sh installs
6nexscope-ai avataramazon-product-researchnexscope-ai/amazon-skillsComprehensive product research and opportunity analysis for Amazon sellers. Analyzes demand, competition, profit potential, market entry barriers, and validates78.3Kskills.sh installs