go-testing
Go testing standards: table-driven tests, testify/require, sentinel errors, mocking, fuzzing, race detection, and test file conventions.
Skill by els0r
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/els0r-go-testing
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/go-testing
What's inside
- Skill name
go-testing- Description
- Go testing standards: table-driven tests, testify/require, sentinel errors, mocking, fuzzing, race detection, and test file conventions. Use this skill whenever writing, reviewing, or discussing Go tests — including unit tests, integration tests, benchmarks, fuzz tests, mocks, or test helpers. Also trigger when the user mentions testify, go-cmp, gock, testcontainers, or asks "how should I test this" for Go code.
- License
- MIT
- Instructions
- 183 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Go Testing
Every piece of logic must be tested.
## Test Libraries
| Library | When to use |
|---------|------------|
| `testify/require` | **Default** — fails fast, clear messages |
| `testify/assert` | Only when the test should continue after a failure |
| `google/go-cmp` | Deep comparisons with custom `cmp.Option`s |
| `gock` | Mock HTTP calls — never hit real endpoints in tests |
| `testcontainers` | Integration tests with external services (databases, queues) |
**Favor `require` over `assert`.** It fails immediately and prevents cascading noise.
## Table-Driven Tests
The default pattern. Use for all new tests.
```go
func TestValidateEmail(t *testing.T) {
tests := []struct {
name string
email string
want bool
wantErr string // use sentinel errors when possible (see go-style)
}{
{"valid email", "user@example.com", true, ""},
{"empty email", "", false, "email cannot be empty"},
{"invalid format", "not-an-email", false, "invalid email format"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ValidateEmail(tt.email)
if tt.wantErr != "" {
require.ErrorContains(t, err, tt.wantErr)
return
}
require.NoError(t, err)
require.Equal(t, tt.want, got)
})
}
}
```
When testing sentinel errors, use `require.ErrorIs(t, err, ErrNotFound)` instead of string matching.
## Test Helpers and Setup
- Mark helpers with `t.Helper()` — no exceptions. Stack traces point to the calling test.
- Use `t.Cleanup(fn)` for teardown instead of `defer` — it runs even if the test calls `t.Fatal`.
- Arrange-act-assert structure. Every time.
```go
func setupTestDB(t *testing.T) *DB {
t.Helper()
db, err := NewDB(":memory:")
require.NoError(t, err)
t.Cleanup(func() { db.Close() })
return db
}
```
## Parallel Tests
Use `t.Parallel()` for independent subtests to speed up suites.
```go
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
// ...
})
}
```
Go 1.22+: loop variable is per-iteration scoped — `tt := tt` capture is no longer needed.
## Mocking
Mock via interfaces. Define mocks in the test file, not production code. Keep them minimal.
```go
type MockEmailSender struct {
Sent []Email
Err error // set to simulate failure
}
func (m *MockEmailSender) Send(to, subject, body string) error {
if m.Err != nil {
return m.Err
}
m.Sent = append(m.Sent, Email{to, subject, body})
return nil
}
```
## Fuzzing
Use `testing.F` for input-discovery testing on parsers, validators, and serialization.
```go
func FuzzParseConfig(f *testing.F) {
f.Add([]byte(`{"key": "value"}`))
f.Add([]byte(`{}`))
f.Fuzz(func(t *testing.T, data []byte) {
cfg, err := ParseConfig(data)
if err != nil {
return // invalid input is expected
}
// round-trip: marshal back and re-parse
out, err := cfg.Marshal()
require.NoError(t, err)
require.Equal(t, cfg, mustParse(t, out))
})
}From els0r/skills, MIT.
More from els0r/skills
- 0.547score
blast-radius
els0r
Produce a risk-ranked audit map of a codebase (especially AI-generated code the user hasn't read), so the human can spend limited reading time where failure…
SkillBFreshness: B★ 1Claude Code +9 - 0.497score
autonomous-orchestration
els0r
Use when the user explicitly hands over multi-PR coordination — asking Claude to follow through on a user story, work bundle, or backlog scope autonomously…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
design-rubric
els0r
Use when critiquing, reviewing, or refining visual designs, wireframes, or UI layouts — especially for small/medium SPAs.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-instrumentation
els0r
Observability principles for Go services: structured logging, distributed tracing, metrics, context propagation, and HTTP service bootstrap.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-performance
els0r
Go performance analysis: memory allocation, CPU bottlenecks, concurrency contention, struct alignment, escape analysis, and benchmarking patterns.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-style
els0r
Go coding conventions, error handling, interface design, and idiomatic patterns.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
improve-go-architecture
els0r
Find deepening opportunities in a Go codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
coding-style
els0r
Use for all code generation, review, and refactoring regardless of language.
SkillCFreshness: C★ 1Claude Code +9 - 0.486score
Codebase Analyzer
els0r
Analyzes codebase implementation details.
SkillCFreshness: C★ 1Claude Code +9 - 0.486score
Codebase Locator
els0r
Locates files, directories, and components relevant to a feature or task.
SkillCFreshness: C★ 1Claude Code +9 - 0.472score
grill-with-docs
els0r
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as…
SkillCFreshness: C★ 1Claude Code +9 - 0.468score
diagnose
els0r
Disciplined diagnosis loop for hard bugs and performance regressions.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 20, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/els0r/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from els0r
- 0.547score
blast-radius
els0r
Produce a risk-ranked audit map of a codebase (especially AI-generated code the user hasn't read), so the human can spend limited reading time where failure…
SkillBFreshness: B★ 1Claude Code +9 - 0.497score
autonomous-orchestration
els0r
Use when the user explicitly hands over multi-PR coordination — asking Claude to follow through on a user story, work bundle, or backlog scope autonomously…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-performance
els0r
Go performance analysis: memory allocation, CPU bottlenecks, concurrency contention, struct alignment, escape analysis, and benchmarking patterns.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-instrumentation
els0r
Observability principles for Go services: structured logging, distributed tracing, metrics, context propagation, and HTTP service bootstrap.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
design-rubric
els0r
Use when critiquing, reviewing, or refining visual designs, wireframes, or UI layouts — especially for small/medium SPAs.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
go-style
els0r
Go coding conventions, error handling, interface design, and idiomatic patterns.
SkillCFreshness: C★ 1Claude Code +9
Cite this page
go-testing skill. Agent Mart. https://agentmart.dev/skills/els0r-go-testing (last updated 2026-10-24)