From go-specialist
Detects white box Go tests (package foo in foo_test.go) and proposes conversion to black box (package foo_test), creating export_test.go for unexported symbols. Enforces via golang-pro agent.
npx claudepluginhub sgaunet/claude-plugins --plugin go-specialistThis skill is limited to using the following tools:
Detect Go test files using white box testing (same package name) and propose conversion to black box testing (`package foo_test`). Creates `export_test.go` bridge files when internal symbols need external test access.
Provides Go testing patterns for production code: subtests, helpers, fixtures, golden files, httptest, testcontainers, property-based, fuzz testing, mocking, isolation, coverage analysis. For writing, reviewing, or improving tests.
Reviews Go test code for table-driven tests, assertions, parallel execution, cleanup, mocking, benchmarks, fuzzing, httptest, and coverage patterns in *_test.go files.
Analyzes Go test code structure directly from files to identify coverage gaps, untested functions, test targets, and organization without running tests.
Share bugs, ideas, or general feedback.
Detect Go test files using white box testing (same package name) and propose conversion to black box testing (package foo_test). Creates export_test.go bridge files when internal symbols need external test access.
*_test.go files during implementation.go file and one *_test.go file to analyze.Use Glob to find all test files:
**/*_test.go
Exclude vendor/ and export_test.go files from analysis.
For each *_test.go file, read the package declaration (first non-comment, non-blank line starting with package).
Classification rules:
| Package declaration | Source package | Classification |
|---|---|---|
package foo_test | foo | Black box (correct) |
package foo | foo | White box (needs conversion) |
package foo_test | N/A (no source) | Black box (standalone) |
To determine the source package: look for non-test .go files in the same directory and read their package declaration.
For each directory containing test files, check whether an export_test.go already exists.
Present a summary table:
| File | Package | Classification | export_test.go |
|---|---|---|---|
calc_test.go | calculator | White box | No |
math_test.go | calculator_test | Black box | N/A |
internal_test.go | parser | White box | Yes |
For each white box test file identified:
Read the test file and identify references to unexported symbols (lowercase-initial identifiers) from the package under test:
Case A — No unexported symbols used:
package foo to package foo_testAdd(1, 2) → calculator.Add(1, 2))Case B — Unexported symbols used:
package foo to package foo_test in the test fileexport_test.go in the same directory with package foo (no _test suffix) that exports needed internals:package foo
// Exported for testing in foo_test package.
var (
TestableInternalFunc = internalFunc
TestableInternalVar = internalVar
)
Case C — Heavy internal coupling (>10 unexported references):
After conversion, run:
go test ./...
go vet ./...
If tests fail, diagnose: missing imports, renamed references, or unexported symbols not yet bridged via export_test.go.
export_test.go (Go convention)_test suffix) — this is what makes it a bridgeexport_test.go only during go testTestable or use the capitalized form of the original name// Exported for testing in <pkg>_test package. header comment| Condition | Action |
|---|---|
No go.mod found | Abort: "Not a Go module." |
| No test files found | Report: "No test files found. Nothing to analyze." |
| All tests already black box | Report: "All test files use black box naming. No conversion needed." |
| Test compilation fails after conversion | Diagnose missing imports or unexported references. Attempt fix (max 2 retries). |
go vet fails after conversion | Display errors and suggest manual review. |