一键导入
writing-go-tests
Applies current Go testing best practices. Use when writing or modifying Go test files or advising on Go testing strategies.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Applies current Go testing best practices. Use when writing or modifying Go test files or advising on Go testing strategies.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | writing-go-tests |
| description | Applies current Go testing best practices. Use when writing or modifying Go test files or advising on Go testing strategies. |
This skill provides actionable testing guidelines. For detailed implementation patterns, code examples, rationale, and production system references, consult go-testing-best-practices.md.
Always apply these current best practices:
*_test.go namingpackage foo_test) for integration testing and exampleshandler_auth_test.go, handler_validation_test.go)testing/synctest for deterministic concurrent testing (Go 1.24+)t.Parallel() first in test functionscmp.Diff() from google/go-cmp for complex comparisonsgo test -cover and go tool cover -html for analysistestdata directory for test fixtures (automatically ignored by Go toolchain)t.Helper() for accurate error reportingt.Cleanup() for resource cleanup (superior to defer in tests)B.Loop() method as the preferred pattern (prevents compiler optimisations)benchstat for statistical analysis-benchmem for memory profilingTest*, Benchmark*, Fuzz*, Example* (capital letter after prefix)got and want for actual vs expected valuesLoad go-testing-best-practices.md when you need:
The detailed guide contains full context, examples with explanations, and production-proven patterns. This SKILL.md provides the actionable rules to apply.
Focus on meaningful tests that validate behaviour rather than implementation. Pragmatic excellence over theoretical perfection.