go-testing▌
cxuu/golang-skills · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Normative: Test failures must be diagnosable without reading the test
- ›source.
Go Testing
Quick Reference
| Pattern | Use When |
|---|---|
t.Error |
Default — report failure, keep running |
t.Fatal |
Setup failed or continuing is meaningless |
cmp.Diff |
Comparing structs, slices, maps, protos |
| Table-driven | Many cases share identical logic |
| Subtests | Need filtering, parallel execution, or naming |
t.Helper() |
Any test helper function (call as first statement) |
t.Cleanup() |
Teardown in helpers instead of defer |
Useful Test Failures
Normative: Test failures must be diagnosable without reading the test source.
Every failure message must include: function name, inputs, actual (got), and
expected (want). Use the format YourFunc(%v) = %v, want %v.
// Good:
t.Errorf("Add(2, 3) = %d, want %d", got, 5)
// Bad: Missing function name and inputs
t.Errorf("got %d, want %d", got, 5)
Always print got before want: got %v, want %v — never reversed.
No Assertion Libraries
Normative: Do not use assertion libraries. Use
cmp.Difffor complex comparisons.
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("GetPost() mismatch (-want +got):\n%s", diff)
}
For protocol buffers, add protocmp.Transform() as a cmp option. Always
include the direction key (-want +got) in diff messages. Avoid comparing
JSON/serialized output — compare semantically instead.
Read references/TEST-HELPERS.md when writing custom comparison helpers or domain-specific test utilities.
t.Error vs t.Fatal
Normative: Use
t.Errorby default to report all failures in one run. Uset.Fatalonly when continuing is impossible.
Choose t.Fatal when:
- Setup fails (DB connection, file load)
- The next assertion depends on the previous one succeeding (e.g., decode after encode)
Never call t.Fatal/t.FailNow from a goroutine other than the test
goroutine — use t.Error instead.
Read references/TEST-HELPERS.md when writing helpers that need to choose between t.Error and t.Fatal, or for detailed examples of both.
Table-Driven Tests
See
assets/table-test-template.gowhen scaffolding a new table-driven test and need the canonical struct, loop, and subtest layout.
Advisory: Use table-driven tests when many cases share identical logic.
Use table tests when: all cases run the same code path with no conditional
setup, mocking, or assertions. A single shouldErr bool is acceptable.
Don't use table tests when: cases need complex setup, conditional mocking, or multiple branches — write separate test functions instead.
Key rules:
- Use field names when cases span many lines or have same-type adjacent fields
- Include inputs in failure messages — never identify rows by index
Read references/TABLE-DRIVEN-TESTS.md when writing table-driven tests, subtests, or parallel tests.
Validation: After generating or modifying tests, run
go test -run TestXxx -vto verify the tests compile and pass. Fix any compilation errors before proceeding.
Test Helpers
Normative: Test helpers must call
t.Helper()first and uset.Cleanup()for teardown.
func setupTestDB(t *testing.T) *sql.DB {
t.Helper()
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
t.Fatalf("Could not open database: %v", err)
}
t.Cleanup(func() { db.Close() })
return db
}
Read references/TEST-HELPERS.md when writing test helpers, cleanup functions, or custom comparison utilities.
Test Error Semantics
Advisory: Test error semantics, not error message strings.
// Bad: Brittle string comparison
if err.Error() != "invalid input" { ... }
// Good: Semantic check
if !errors.Is(err, ErrInvalidInput) { ... }
For simple presence checks when specific semantics don't matter:
if gotErr := err != nil; gotErr != tt.wantErr {
t.Errorf("f(%v) error = %v, want error presence = %t", tt.input, err, tt.wantErr)
}
Test Organization
Read references/TEST-ORGANIZATION.md when working with test doubles, choosing test package placement, or scoping test setup.
Read references/VALIDATION-APIS.md when designing reusable test validation functions.
Integration Testing
Read references/INTEGRATION.md when writing TestMain, acceptance tests, or tests that need real HTTP/RPC transports.
Available Scripts
scripts/gen-table-test.sh— Generates a table-driven test scaffold
bash scripts/gen-table-test.sh ParseConfig config > config/parse_config_test.go
bash scripts/gen-table-test.sh --parallel ParseConfig config # with t.Parallel()
bash scripts/gen-table-test.sh --output config/parse_config_test.go ParseConfig config
Related Skills
- Error testing: See go-error-handling when testing error semantics with
errors.Is/errors.Asor sentinel errors - Interface mocking: See go-interfaces when creating test doubles by implementing interfaces at the consumer side
- Naming test functions: See go-naming when naming test functions, subtests, or test helper utilities
- Linter integration: See go-linting when running linters alongside tests in CI or pre-commit hooks
How to use go-testing on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add go-testing
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches go-testing from GitHub repository cxuu/golang-skills and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate go-testing. Access the skill through slash commands (e.g., /go-testing) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.6★★★★★25 reviews- ★★★★★Carlos Ghosh· Dec 24, 2024
Registry listing for go-testing matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Shikha Mishra· Dec 12, 2024
go-testing reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Sofia Bhatia· Nov 15, 2024
Useful defaults in go-testing — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Rahul Santra· Nov 3, 2024
I recommend go-testing for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Pratham Ware· Oct 22, 2024
Useful defaults in go-testing — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Carlos Gonzalez· Oct 6, 2024
I recommend go-testing for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Oshnikdeep· Sep 13, 2024
go-testing has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Maya Harris· Sep 1, 2024
Registry listing for go-testing matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Aanya Brown· Aug 20, 2024
go-testing reduced setup friction for our internal harness; good balance of opinion and flexibility.
- ★★★★★Ganesh Mohane· Aug 4, 2024
Solid pick for teams standardizing on skills: go-testing is focused, and the summary matches what you get after install.
showing 1-10 of 25