Skip to content

ofershap/go-best-practices

Repository files navigation

Go Best Practices

Modern Go patterns — error handling, concurrency, structured logging with slog, and Go 1.22+ features agents miss.

Install

Cursor IDE

/add-plugin go-best-practices

Claude Code

/plugin install go-best-practices

Skills only (any agent)

npx skills add ofershap/go-best-practices/go-best-practices

Or copy skills/ into your .cursor/skills/ or .claude/skills/ directory.

What's Included

Skills

  • go-best-practices - Modern Go patterns — error handling, concurrency, structured logging with slog, and Go 1.22+ features agents miss

Rules

  • best-practices - Always-on rules that enforce current Go patterns

Commands

  • /audit - Scan your codebase for Go anti-patterns

Why This Plugin?

AI agents are trained on data that includes outdated Go patterns. This plugin ensures your agent uses current best practices:

  • Pre-1.22 Go — Agents generate C-style for loops and unnecessary loop variable shadow copies. Go 1.22+ has range over int and fixed capture.
  • log.Printf instead of slog — Structured logging with slog has been standard since Go 1.21. Agents still use the legacy log package.
  • Bare error propagation — Agents return err without wrapping. Errors need context at each level for debugging.
  • Goroutine leaks — Agents spawn goroutines without exit paths. Leaked goroutines consume memory indefinitely.
  • Wrong error checks — Agents use == or type assertion. Wrapped errors require errors.Is and errors.As.

License

MIT

About

Modern Go patterns — error handling, concurrency, structured logging with slog, and Go 1.22+ features agents miss

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors