Skip to content
Back to skills

Go

ASecurity

This skill should be used when the user works with Go files (.go), asks about "error handling", "interfaces", "goroutines", or discusses Go idioms and concurrency.

  • 23 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 3, 2026
developmentgo

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned November 9, 2026

npx -y skills add dean0x/devflow --skill go --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Go?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Go
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dean0x-devflow/badge)](https://www.skillsdirectory.com/skills/dean0x-devflow)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: go
description: This skill should be used when the user works with Go files (.go), asks about "error handling", "interfaces", "goroutines", or discusses Go idioms and concurrency.
user-invocable: false
allowed-tools: Read, Grep, Glob
activation:
  file-patterns:
    - "**/*.go"
  exclude:
    - "vendor/**"
---

# Go Patterns

Full bibliography: `references/sources.md`.

## Iron Law

> **ERRORS ARE VALUES** [5][7]
>
> Never ignore errors. `if err != nil` is correctness, not boilerplate. Every error
> return must be checked, wrapped with context, or explicitly documented as intentionally
> ignored with `_ = fn()`. "Errors are values. Values can be programmed." — Rob Pike [5]

## Error Handling

- Wrap with context, `return fmt.Errorf("finding user %s: %w", id, err)`, not a bare `return err`: the caller loses context.
- Declare sentinel errors (`var ErrNotFound = errors.New("not found")`) and match them with `errors.Is`.
- Never discard an error with `val, _ := fn()`: check it, wrap it, or ignore it on purpose with `_ = fn()`.
- No `panic` or `log.Fatal` in library code.

## Interface Design

- Accept interfaces: `NewService(repo Repository)`, not `NewService(repo *PostgresRepo)`.
- Define an interface at the consumer when it is used, not at the producer before use.
- Keep interfaces small (1-3 methods) and compose them (`ReadWriter` embeds `Reader` and `Writer`).

## Concurrency

- Do not communicate by sharing memory; share memory by communicating.
- Pass `context.Context` as the first parameter.
- Give every goroutine a clear lifecycle and cancellation, for example `errgroup.WithContext`. A bare `go fn()` leaks.
- Specify channel direction in signatures: `chan<- int`, `<-chan int`.

## Package Design and Zero Values

- Organize packages by domain (`user/`, `order/`), not by type (`models/`, `controllers/`). Keep internals unexported.
- Make zero values ready to use (`sync.Mutex`, `bytes.Buffer`; a zero `Timeout` means no timeout).
- No naked `return` in functions with named returns.
- No complex `init()` with side effects.

## Extended References

- `references/sources.md` — Full bibliography
- `references/violations.md` — Violations with citations
- `references/patterns.md` — Extended patterns with citations
- `references/detection.md` — Grep patterns for automated detection
- `references/concurrency.md` — CSP-grounded concurrency patterns

Files in this skill

  • SKILL.md4.3 KB
  • references/concurrency.md7.6 KB
  • references/detection.md3 KB
  • references/patterns.md6.6 KB
  • references/sources.md4.2 KB
  • references/violations.md6.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.