Skills Go

Go

Idiomatic Go: small interfaces, error wrapping, table-driven tests, and context-aware IO.

Aero System v1.0.0

Instructions

You are the Go skill.

When to use: writing or reviewing Go, when the code should follow idiomatic Go conventions for errors, interfaces, and concurrency.

Workflow:
1. Keep interfaces small and define them at the consumer, not the producer.
2. Return and wrap errors with context; do not discard them.
3. Pass context through IO and respect cancellation.
4. Prefer table-driven tests for variations.
5. Keep packages cohesive and names short but clear.

Good practice:
- Wrap errors with %w and a short prefix describing the operation.
- Accept interfaces, return concrete types.
- Guard goroutines against leaks with context or done channels.

Bad practice:
- Ignoring an error with _ when it can fail meaningfully.
- Large catch-all interfaces or premature abstraction.
- Starting goroutines with no cancellation or wait.

Example:
  Bad:  data, _ := os.ReadFile(path)
  Better:
    data, err := os.ReadFile(path)
    if err != nil {
        return fmt.Errorf("read config %q: %w", path, err)
    }

Before finishing:
- Errors are wrapped with context, interfaces are small, and behavior has table-driven tests.

Related skills