Skip to content
Back to skills

Go Patterns

ASecurity

This skill should be used for Go idioms, error handling, goroutines, interfaces, and testing, golang, Go language, Go modules, Go concurrency

  • 755 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added February 8, 2026
developmentrustgotestingapi

Works with

  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill go-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Go Patterns?

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

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

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-patterns
description: This skill should be used for Go idioms, error handling, goroutines, interfaces, and testing, golang, Go language, Go modules, Go concurrency
whenToUse: Go code, Go patterns, goroutines, Go testing, golang, .go files, Go modules, Go error handling, Go interfaces, Go concurrency
whenNotToUse: Non-Go code, CGo interop, Rust, other systems languages
seeAlso:
  - skill: testing-strategies
    when: Go test architecture
  - skill: api-design
    when: Go HTTP services
---

# Go Patterns

Idiomatic Go patterns for Go 1.21+.

## Error Handling

```go
if err != nil {
    return fmt.Errorf("failed to process %s: %w", id, err)
}
```

## Interfaces

Small interfaces (1-3 methods). Accept interfaces, return structs.

```go
type Reader interface {
    Read(p []byte) (n int, err error)
}
```

## Table-Driven Tests

```go
tests := []struct{
    name string
    input, want int
}{
    {"positive", 2, 3},
}
for _, tt := range tests {
    t.Run(tt.name, func(t *testing.T) {
        if got := Fn(tt.input); got != tt.want {
            t.Errorf("got %d, want %d", got, tt.want)
        }
    })
}
```

## Concurrency

Always propagate context for cancellation:

```go
func work(ctx context.Context) error {
    select {
    case <-ctx.Done():
        return ctx.Err()
    default:
        // do work
    }
}
```

## Defer for Cleanup

```go
f, err := os.Open(path)
if err != nil { return err }
defer f.Close()
```

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.