go
What it does
This guide teaches best practices for writing code in the Go programming language. It shows how to handle errors, use lists (slices) and dictionaries (maps), and manage concurrent tasks (goroutines and channels) efficiently and clearly.
When to use it
- βWhen learning to program in Go.
- βWhen reviewing or improving existing Go code.
- βWhen encountering common Go errors.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/super-code/go/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow can I handle errors correctly in Go?β
5 new skills a week. 1 minute to read.
How it works
The guide compares 'bad' code examples with 'good' ones to illustrate recommended practices. It explains why one approach is better than another, focusing on clarity and efficiency.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Go: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for go.
Table of Contents
- Error Handling
- Slices & Maps
- Goroutines & Channels
- Structs & Interfaces
- Functions & Closures
- Anti-patterns specific to Go
1. Error Handling {#errors}
// β Ignoring errors
result, _ := os.Open(path)
// β
β always handle; only use _ when error is provably irrelevant
result, err := os.Open(path)
if err != nil {
return fmt.Errorf("open %s: %w", path, err)
}
// β Redundant error variable
err := doA()
if err != nil { return err }
err = doB()
if err != nil { return err }
// β
β each :=/: is fine; this is idiomatic Go. Don't try to "fix" it.
// What you CAN simplify: collapsing to one-liners where the if body is a single return
if err := doA(); err != nil { return err }
if err := doB(); err != nil { return err }
// β Custom error type with no added value
type MyError struct{ msg string }
func (e MyError) Error() string { return e.msg }
// β
β use errors.New or fmt.Errorf unless callers need to inspect type
var ErrNotFound = errors.New("not found")
return fmt.Errorf("lookup %q: %w", key, ErrNotFound)
Wrap errors with %w (not %v) so callers can use errors.Is / errors.As.
2. Slices & Maps {#slices}
// β Growing a slice without pre-allocation when size is known
var result []string
for _, item := range items {
result = append(result, item.Name)
}
// β
result := make([]string, 0, len(items))
for _, item := range items {
result = append(result, item.Name)
}
// β Manual existence check before map write
if _, ok := m[key]; !ok {
m[key] = []string{}
}
m[key] = append(m[key], value)
// β
β append to nil slice is valid Go
m[key] = append(m[key], value)
// β Copying a map by assignment (copies reference)
copy := original
// β
copy := make(map[K]V, len(original))
for k, v := range original { copy[k] = v }
3. Goroutines & Channels {#concurrency}
// β Fire-and-forget goroutine with no lifecycle
go doWork()
// β
β use errgroup or WaitGroup to track completion
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
doWork()
}()
wg.Wait()
// β Unbuffered channel causing unnecessary goroutine block
ch := make(chan Result)
go func() { ch <- compute() }()
result := <-ch
// β
β for single-result, buffered channel avoids goroutine leak if receiver exits early
ch := make(chan Result, 1)
go func() { ch <- compute() }()
result := <-ch
// β select with a busy-wait default
for {
select {
case v := <-ch:
process(v)
default:
// spin
}
}
// β
β blocking select unless you genuinely need non-blocking
for v := range ch {
process(v)
}
Use golang.org/x/sync/errgroup for fan-out with error collection.
4. Structs & Interfaces {#structs}
// β Large interface
type Storage interface {
Get(key string) ([]byte, error)
Set(key string, val []byte) error
Delete(key string) error
List(prefix string) ([]string, error)
// ... 10 more methods
}
// β
β small, composable interfaces
type Getter interface { Get(key string) ([]byte, error) }
type Setter interface { Set(key string, val []byte) error }
type Storage interface { Getter; Setter }
// β Returning concrete struct from constructor (ties callers to implementation)
func NewStore() *RedisStore { ... }
// β
β return interface when you have or anticipate multiple implementations
func NewStore() Storage { return &RedisStore{...} }
// β Pointer receiver for tiny value types
func (p *Point) X() float64 { return p.x }
// β
β value receiver for small immutable types
func (p Point) X() float64 { return p.x }
Rule: pointer receiver when method mutates state OR struct is large (>3 fields of non-trivial size). Value receiver otherwise.
5. Functions & Closures {#functions}
// β Named return values used just to avoid a variable declaration
func divide(a, b float64) (result float64, err error) {
result = a / b
return
}
// β
β named returns are worth it only for deferred mutation or documentation
func divide(a, b float64) (float64, error) {
if b == 0 { return 0, errors.New("division by zero") }
return a / b, nil
}
β¦
FAQ
What are 'goroutines' and 'channels'?
They are Go's tools for running multiple tasks at the same time (goroutines) and for those tasks to communicate safely (channels).
Why is it important to 'wrap' errors with `%w`?
Using `%w` allows the code receiving the error to check if it originated from a specific error, using functions like `errors.Is` or `errors.As`.
What are 'anti-patterns'?
These are programming practices that, while they might work, often lead to more confusing, inefficient, or error-prone code. The guide shows how to avoid them in Go.
Details
Original description by the author
Language-specific super-code guidelines for go.
Popularity
- GitHub stars
- 48k
- Ranking position
- #5892
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.