Back to list
Zate

go-patterns

by Zate

4🍴 0📅 Jan 24, 2026

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

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

Interfaces

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

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

Table-Driven Tests

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:

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

Defer for Cleanup

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

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon