golang-testing

Generate and review Go tests with table-driven subtests and goleak detection.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/dashkan/pivox --skill golang-testing-dashkan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-testing
Source: https://github.com/dashkan/pivox/tree/main/.agents/skills/golang-testing
Command: npx skills add https://github.com/dashkan/pivox --skill golang-testing-dashkan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires go, gotests, go.uber.org/goleak, github.com/cweill/gotests/gotests, testing/synctest, and includes references (resource) components.

What problem does it solve?

This Skill solves flaky, low-signal Go testing by helping you write production-ready tests that constrain behavior, stay fast, and reliably detect concurrency issues.

Core Features & Use Cases

  • Table-driven tests with named subtests: Ensures each case is individually debuggable and easy to expand (e.g., edge cases like validation failures).
  • Correct separation of unit vs integration tests: Uses build tags for deterministic CI runs and prevents accidental DB/network calls in normal test runs.
  • Flake prevention and correctness checks: Recommends parallelism when safe, goroutine leak detection via goleak, and deterministic time testing patterns for concurrency-heavy code.

Quick Start

Use the golang-testing skill to generate or review Go tests using table-driven named subtests, build-tagged integration tests, and goleak-based goroutine leak detection where appropriate.

Frequently Asked Questions about golang-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write table-driven Go tests with named subtests?

Table-driven Go tests use t.Run to create named subtests, ensuring each case is individually debuggable and easy to expand with edge cases like validation failures. This structure keeps tests maintainable and fast.

How do I separate integration tests from unit tests in Go CI workflows?

Separate integration tests from unit tests using //go:build integration build tags. This prevents accidental database or network calls during normal test runs, ensuring deterministic CI execution.

What's the best way to detect goroutine leaks in Go concurrency tests?

Detect goroutine leaks in Go concurrency tests using go.uber.org/goleak. This library identifies leaked goroutines in CI workflows, preventing flaky tests and ensuring reliable concurrency management.

How do I test deterministic time-dependent logic in Go?

Test deterministic time-dependent logic in Go using testing/synctest. This package provides deterministic time testing patterns essential for validating concurrency-heavy code without flaky time delays.

Can I use gotests to generate idiomatic Go test structures?

Yes, gotests generates idiomatic Go test structures with table-driven named subtests. It scaffolds test functions that cover error paths without order dependence, improving test reliability and maintainability.

Why does my Go test flake when running concurrent code?

Go tests flake when concurrent code lacks deterministic strategies or leaks goroutines. Apply t.Parallel when safe, use goleak for leak detection, and adopt synctest for deterministic time testing to prevent flakes.