[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JGTF2GHR7W0SP5GYGTQ8EP":3,"skill-same:01M6JGTF2GHR7W0SP5GYGTQ8EP":111},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":28,"publishedAt":49,"linkOnly":50,"markdownContent":51,"markdownBody":52,"frontMatter":53,"refName":60,"commitSha":61,"skillDirectory":62,"forksCount":63,"repositoryHtmlUrl":64,"repositoryHomepageUrl":6,"ownerHtmlUrl":65,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":66,"install":67,"resources":79},"01M6JGTF2GHR7W0SP5GYGTQ8EP","golang-testing",null,"Provides a comprehensive guide for writing production-ready Golang tests. Covers table-driven tests, test suites with testify, mocks, unit tests, integration tests, benchmarks, code coverage, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, memory leaks, CI with GitHub Actions, and idiomatic naming conventions. Use this whenever writing tests, asking about testing patterns or setting up CI for Go projects. Essential for ANY test-related conversation in Go.","muratovv\u002Fai-hats","muratovv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F7502801?v=4","01M6JGCBN4KEJX012GPJVSH04T","Fedor Muratov","01M6JGCBSNMN7CW3RGTPPE0MN2",3,"MIT","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"golang","testing","golang testing","Bash","production-ready","unit","conversation","up","ready","coverage","read","projects","testing patterns","github actions","ci","actions","code","ai coding agents","memory","writing","2026-11-10 10:12:30",false,"---\nname: golang-testing\ndescription: >-\n  Provides a comprehensive guide for writing production-ready Golang\n  tests. Covers table-driven tests, test suites with testify, mocks, unit\n  tests, integration tests, benchmarks, code coverage, parallel tests,\n  fuzzing, fixtures, goroutine leak detection with goleak, snapshot\n  testing, memory leaks, CI with GitHub Actions, and idiomatic naming\n  conventions. Use this whenever writing tests, asking about testing\n  patterns or setting up CI for Go projects. Essential for ANY\n  test-related conversation in Go.\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code or similar AI coding agents, and for projects using Golang.\nmetadata:\n  author: samber\n  version: \"1.1.2\"\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent Bash(gotests:*) AskUserQuestion\n---\n\n**Persona:** You are a Go engineer who treats tests as executable specifications. You write tests to constrain behavior, not to hit coverage targets.\n\n**Thinking mode:** Use `ultrathink` for test strategy design and failure analysis. Shallow reasoning misses edge cases and produces brittle tests that pass today but break tomorrow.\n\n**Modes:**\n\n- **Write mode** — generating new tests for existing or new code. Work sequentially through the code under test; use `gotests` to scaffold table-driven tests, then enrich with edge cases and error paths.\n- **Review mode** — reviewing a PR's test changes. Focus on the diff: check coverage of new behaviour, assertion quality, table-driven structure, and absence of flakiness patterns. Sequential.\n- **Audit mode** — auditing an existing test suite for gaps, flakiness, or bad patterns (order-dependent tests, missing `t.Parallel()`, implementation-detail coupling). Launch up to 3 parallel sub-agents split by concern: (1) unit test quality and coverage gaps, (2) integration test isolation and build tags, (3) goroutine leaks and race conditions.\n- **Debug mode** — a test is failing or flaky. Work sequentially: reproduce reliably, isolate the failing assertion, trace the root cause in production code or test setup.\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-testing` skill takes precedence.\n\n# Go Testing Best Practices\n\nThis skill guides the creation of production-ready tests for Go applications. Follow these principles to write maintainable, fast, and reliable tests.\n\n## Best Practices Summary\n\n1. Table-driven tests MUST use named subtests -- every test case needs a `name` field passed to `t.Run`\n2. Integration tests MUST use build tags (`\u002F\u002Fgo:build integration`) to separate from unit tests\n3. Tests MUST NOT depend on execution order -- each test MUST be independently runnable\n4. Independent tests SHOULD use `t.Parallel()` when possible\n5. NEVER test implementation details -- test observable behavior and public API contracts\n6. Packages with goroutines SHOULD use `goleak.VerifyTestMain` in `TestMain` to detect goroutine leaks\n7. Use testify as helpers, not a replacement for standard library\n8. Mock interfaces, not concrete types\n9. Keep unit tests fast (\u003C 1ms), use build tags for integration tests\n10. Run tests with race detection in CI\n11. Include examples as executable documentation\n\n## Test Structure and Organization\n\n### File Conventions\n\n```go\n\u002F\u002F package_test.go - tests in same package (white-box, access unexported)\npackage mypackage\n\n\u002F\u002F mypackage_test.go - tests in test package (black-box, public API only)\npackage mypackage_test\n```\n\n### Naming Conventions\n\n```go\nfunc TestAdd(t *testing.T) { ... }              \u002F\u002F function test\nfunc TestMyStruct_MyMethod(t *testing.T) { ... } \u002F\u002F method test\nfunc BenchmarkAdd(b *testing.B) { ... }          \u002F\u002F benchmark\nfunc ExampleAdd() { ... }                        \u002F\u002F example\n```\n\n## Table-Driven Tests\n\nTable-driven tests are the idiomatic Go way to test multiple scenarios. Always name each test case.\n\n```go\nfunc TestCalculatePrice(t *testing.T) {\n    tests := []struct {\n        name     string\n        quantity int\n        unitPrice float64\n        expected  float64\n    }{\n        {\n            name:      \"single item\",\n            quantity:  1,\n            unitPrice: 10.0,\n            expected:  10.0,\n        },\n        {\n            name:      \"bulk discount - 100 items\",\n            quantity:  100,\n            unitPrice: 10.0,\n            expected:  900.0, \u002F\u002F 10% discount\n        },\n        {\n            name:      \"zero quantity\",\n            quantity:  0,\n            unitPrice: 10.0,\n            expected:  0.0,\n        },\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got := CalculatePrice(tt.quantity, tt.unitPrice)\n            if got != tt.expected {\n                t.Errorf(\"CalculatePrice(%d, %.2f) = %.2f, want %.2f\",\n                    tt.quantity, tt.unitPrice, got, tt.expected)\n            }\n        })\n    }\n}\n```\n\n## Unit Tests\n\nUnit tests should be fast (\u003C 1ms), isolated (no external dependencies), and deterministic.\n\n## Testing HTTP Handlers\n\nUse `httptest` for handler tests with table-driven patterns. See [HTTP Testing](.\u002Freferences\u002Fhttp-testing.md) for examples with request\u002Fresponse bodies, query parameters, headers, and status code assertions.\n\n## Goroutine Leak Detection with goleak\n\nUse `go.uber.org\u002Fgoleak` to detect leaking goroutines, especially for concurrent code:\n\n```go\nimport (\n    \"testing\"\n    \"go.uber.org\u002Fgoleak\"\n)\n\nfunc TestMain(m *testing.M) {\n    goleak.VerifyTestMain(m)\n}\n```\n\nTo exclude specific goroutine stacks (for known leaks or library goroutines):\n\n```go\nfunc TestMain(m *testing.M) {\n    goleak.VerifyTestMain(m,\n        goleak.IgnoreCurrent(),\n    )\n}\n```\n\nOr per-test:\n\n```go\nfunc TestWorkerPool(t *testing.T) {\n    defer goleak.VerifyNone(t)\n    \u002F\u002F ... test code ...\n}\n```\n\n## testing\u002Fsynctest for Deterministic Goroutine Testing\n\n> **Experimental:** `testing\u002Fsynctest` is not yet covered by Go's compatibility guarantee. Its API may change in future releases. For stable alternatives, use `clockwork` (see [Mocking](.\u002Freferences\u002Fmocking.md)).\n\n`testing\u002Fsynctest` (Go 1.24+) provides deterministic time for concurrent code testing. Time advances only when all goroutines are blocked, making ordering predictable.\n\nWhen to use `synctest` instead of real time:\n\n- Testing concurrent code with time-based operations (time.Sleep, time.After, time.Ticker)\n- When race conditions need to be reproducible\n- When tests are flaky due to timing issues\n\n```go\nimport (\n    \"testing\"\n    \"time\"\n    \"testing\u002Fsynctest\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n)\n\nfunc TestChannelTimeout(t *testing.T) {\n    synctest.Run(func(t *testing.T) {\n        is := assert.New(t)\n\n        ch := make(chan int, 1)\n        go func() {\n            time.Sleep(50 * time.Millisecond)\n            ch \u003C- 42\n        }()\n\n        select {\n        case v := \u003C-ch:\n            is.Equal(42, v)\n        case \u003C-time.After(100 * time.Millisecond):\n            t.Fatal(\"timeout occurred\")\n        }\n    })\n}\n```\n\nKey differences in `synctest`:\n\n- `time.Sleep` advances synthetic time instantly when the goroutine blocks\n- `time.After` fires when synthetic time reaches the duration\n- All goroutines run to blocking points before time advances\n- Test execution is deterministic and repeatable\n\n## Test Timeouts\n\nFor tests that may hang, use a timeout helper that panics with caller location. See [Helpers](.\u002Freferences\u002Fhelpers.md).\n\n## Benchmarks\n\n→ See `samber\u002Fcc-skills-golang@golang-benchmark` skill for advanced benchmarking: `b.Loop()` (Go 1.24+), `benchstat`, profiling from benchmarks, and CI regression detection.\n\nWrite benchmarks to measure performance and detect regressions:\n\n```go\nfunc BenchmarkStringConcatenation(b *testing.B) {\n    b.Run(\"plus-operator\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            result := \"a\" + \"b\" + \"c\"\n            _ = result\n        }\n    })\n\n    b.Run(\"strings.Builder\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var builder strings.Builder\n            builder.WriteString(\"a\")\n            builder.WriteString(\"b\")\n            builder.WriteString(\"c\")\n            _ = builder.String()\n        }\n    })\n}\n```\n\nBenchmarks with different input sizes:\n\n```go\nfunc BenchmarkFibonacci(b *testing.B) {\n    sizes := []int{10, 20, 30}\n    for _, size := range sizes {\n        b.Run(fmt.Sprintf(\"n=%d\", size), func(b *testing.B) {\n            b.ReportAllocs()\n            for i := 0; i \u003C b.N; i++ {\n                Fibonacci(size)\n            }\n        })\n    }\n}\n```\n\n## Parallel Tests\n\nUse `t.Parallel()` to run tests concurrently:\n\n```go\nfunc TestParallelOperations(t *testing.T) {\n    tests := []struct {\n        name string\n        data []byte\n    }{\n        {\"small data\", make([]byte, 1024)},\n        {\"medium data\", make([]byte, 1024*1024)},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel()\n            is := assert.New(t)\n\n            result := Process(tt.data)\n            is.NotNil(result)\n        })\n    }\n}\n```\n\n## Fuzzing\n\nUse fuzzing to find edge cases and bugs:\n\n```go\nfunc FuzzReverse(f *testing.F) {\n    f.Add(\"hello\")\n    f.Add(\"\")\n    f.Add(\"a\")\n\n    f.Fuzz(func(t *testing.T, input string) {\n        reversed := Reverse(input)\n        doubleReversed := Reverse(reversed)\n        if input != doubleReversed {\n            t.Errorf(\"Reverse(Reverse(%q)) = %q, want %q\", input, doubleReversed, input)\n        }\n    })\n}\n```\n\n## Examples as Documentation\n\nExamples are executable documentation verified by `go test`:\n\n```go\nfunc ExampleCalculatePrice() {\n    price := CalculatePrice(100, 10.0)\n    fmt.Printf(\"Price: %.2f\\n\", price)\n    \u002F\u002F Output: Price: 900.00\n}\n\nfunc ExampleCalculatePrice_singleItem() {\n    price := CalculatePrice(1, 25.50)\n    fmt.Printf(\"Price: %.2f\\n\", price)\n    \u002F\u002F Output: Price: 25.50\n}\n```\n\n## Code Coverage\n\n```bash\n# Generate coverage file\ngo test -coverprofile=coverage.out .\u002F...\n\n# View coverage in HTML\ngo tool cover -html=coverage.out\n\n# Coverage by function\ngo tool cover -func=coverage.out\n\n# Total coverage percentage\ngo tool cover -func=coverage.out | grep total\n```\n\n## Integration Tests\n\nUse build tags to separate integration tests from unit tests:\n\n```go\n\u002F\u002Fgo:build integration\n\npackage mypackage\n\nfunc TestDatabaseIntegration(t *testing.T) {\n    db, err := sql.Open(\"postgres\", os.Getenv(\"DATABASE_URL\"))\n    if err != nil {\n        t.Fatal(err)\n    }\n    defer db.Close()\n\n    \u002F\u002F Test real database operations\n}\n```\n\nRun integration tests separately:\n\n```bash\ngo test -tags=integration .\u002F...\n```\n\nFor Docker Compose fixtures, SQL schemas, and integration test suites, see [Integration Testing](.\u002Freferences\u002Fintegration-testing.md).\n\n## Mocking\n\nMock interfaces, not concrete types. Define interfaces where consumed, then create mock implementations.\n\nFor mock patterns, test fixtures, and time mocking, see [Mocking](.\u002Freferences\u002Fmocking.md).\n\n## Enforce with Linters\n\nMany test best practices are enforced automatically by linters: `thelper`, `paralleltest`, `testifylint`. See the `samber\u002Fcc-skills-golang@golang-linter` skill for configuration and usage.\n\n## Cross-References\n\n- -> See `samber\u002Fcc-skills-golang@golang-stretchr-testify` skill for detailed testify API (assert, require, mock, suite)\n- -> See `samber\u002Fcc-skills-golang@golang-database` skill (testing.md) for database integration test patterns\n- -> See `samber\u002Fcc-skills-golang@golang-concurrency` skill for goroutine leak detection with goleak\n- -> See `samber\u002Fcc-skills-golang@golang-continuous-integration` skill for CI test configuration and GitHub Actions workflows\n- -> See `samber\u002Fcc-skills-golang@golang-linter` skill for testifylint and paralleltest configuration\n\n## Quick Reference\n\n```bash\ngo test .\u002F...                          # all tests\ngo test -run TestName .\u002F...            # specific test by exact name\ngo test -run TestName\u002Fsubtest .\u002F...    # subtests within a test\ngo test -run 'Test(Add|Sub)' .\u002F...     # multiple tests (regexp OR)\ngo test -run 'Test[A-Z]' .\u002F...         # tests starting with capital letter\ngo test -run 'TestUser.*' .\u002F...        # tests matching prefix\ngo test -run '.*Validation.*' .\u002F...    # tests containing substring\ngo test -run TestName\u002F. .\u002F...          # all subtests of TestName\ngo test -run '\u002F(unit|integration)' .\u002F... # filter by subtest name\ngo test -race .\u002F...                    # race detection\ngo test -cover .\u002F...                   # coverage summary\ngo test -bench=. -benchmem .\u002F...       # benchmarks\ngo test -fuzz=FuzzName .\u002F...           # fuzzing\ngo test -tags=integration .\u002F...        # integration tests\n```\n","**Persona:** You are a Go engineer who treats tests as executable specifications. You write tests to constrain behavior, not to hit coverage targets.\n\n**Thinking mode:** Use `ultrathink` for test strategy design and failure analysis. Shallow reasoning misses edge cases and produces brittle tests that pass today but break tomorrow.\n\n**Modes:**\n\n- **Write mode** — generating new tests for existing or new code. Work sequentially through the code under test; use `gotests` to scaffold table-driven tests, then enrich with edge cases and error paths.\n- **Review mode** — reviewing a PR's test changes. Focus on the diff: check coverage of new behaviour, assertion quality, table-driven structure, and absence of flakiness patterns. Sequential.\n- **Audit mode** — auditing an existing test suite for gaps, flakiness, or bad patterns (order-dependent tests, missing `t.Parallel()`, implementation-detail coupling). Launch up to 3 parallel sub-agents split by concern: (1) unit test quality and coverage gaps, (2) integration test isolation and build tags, (3) goroutine leaks and race conditions.\n- **Debug mode** — a test is failing or flaky. Work sequentially: reproduce reliably, isolate the failing assertion, trace the root cause in production code or test setup.\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-testing` skill takes precedence.\n\n# Go Testing Best Practices\n\nThis skill guides the creation of production-ready tests for Go applications. Follow these principles to write maintainable, fast, and reliable tests.\n\n## Best Practices Summary\n\n1. Table-driven tests MUST use named subtests -- every test case needs a `name` field passed to `t.Run`\n2. Integration tests MUST use build tags (`\u002F\u002Fgo:build integration`) to separate from unit tests\n3. Tests MUST NOT depend on execution order -- each test MUST be independently runnable\n4. Independent tests SHOULD use `t.Parallel()` when possible\n5. NEVER test implementation details -- test observable behavior and public API contracts\n6. Packages with goroutines SHOULD use `goleak.VerifyTestMain` in `TestMain` to detect goroutine leaks\n7. Use testify as helpers, not a replacement for standard library\n8. Mock interfaces, not concrete types\n9. Keep unit tests fast (\u003C 1ms), use build tags for integration tests\n10. Run tests with race detection in CI\n11. Include examples as executable documentation\n\n## Test Structure and Organization\n\n### File Conventions\n\n```go\n\u002F\u002F package_test.go - tests in same package (white-box, access unexported)\npackage mypackage\n\n\u002F\u002F mypackage_test.go - tests in test package (black-box, public API only)\npackage mypackage_test\n```\n\n### Naming Conventions\n\n```go\nfunc TestAdd(t *testing.T) { ... }              \u002F\u002F function test\nfunc TestMyStruct_MyMethod(t *testing.T) { ... } \u002F\u002F method test\nfunc BenchmarkAdd(b *testing.B) { ... }          \u002F\u002F benchmark\nfunc ExampleAdd() { ... }                        \u002F\u002F example\n```\n\n## Table-Driven Tests\n\nTable-driven tests are the idiomatic Go way to test multiple scenarios. Always name each test case.\n\n```go\nfunc TestCalculatePrice(t *testing.T) {\n    tests := []struct {\n        name     string\n        quantity int\n        unitPrice float64\n        expected  float64\n    }{\n        {\n            name:      \"single item\",\n            quantity:  1,\n            unitPrice: 10.0,\n            expected:  10.0,\n        },\n        {\n            name:      \"bulk discount - 100 items\",\n            quantity:  100,\n            unitPrice: 10.0,\n            expected:  900.0, \u002F\u002F 10% discount\n        },\n        {\n            name:      \"zero quantity\",\n            quantity:  0,\n            unitPrice: 10.0,\n            expected:  0.0,\n        },\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            got := CalculatePrice(tt.quantity, tt.unitPrice)\n            if got != tt.expected {\n                t.Errorf(\"CalculatePrice(%d, %.2f) = %.2f, want %.2f\",\n                    tt.quantity, tt.unitPrice, got, tt.expected)\n            }\n        })\n    }\n}\n```\n\n## Unit Tests\n\nUnit tests should be fast (\u003C 1ms), isolated (no external dependencies), and deterministic.\n\n## Testing HTTP Handlers\n\nUse `httptest` for handler tests with table-driven patterns. See [HTTP Testing](.\u002Freferences\u002Fhttp-testing.md) for examples with request\u002Fresponse bodies, query parameters, headers, and status code assertions.\n\n## Goroutine Leak Detection with goleak\n\nUse `go.uber.org\u002Fgoleak` to detect leaking goroutines, especially for concurrent code:\n\n```go\nimport (\n    \"testing\"\n    \"go.uber.org\u002Fgoleak\"\n)\n\nfunc TestMain(m *testing.M) {\n    goleak.VerifyTestMain(m)\n}\n```\n\nTo exclude specific goroutine stacks (for known leaks or library goroutines):\n\n```go\nfunc TestMain(m *testing.M) {\n    goleak.VerifyTestMain(m,\n        goleak.IgnoreCurrent(),\n    )\n}\n```\n\nOr per-test:\n\n```go\nfunc TestWorkerPool(t *testing.T) {\n    defer goleak.VerifyNone(t)\n    \u002F\u002F ... test code ...\n}\n```\n\n## testing\u002Fsynctest for Deterministic Goroutine Testing\n\n> **Experimental:** `testing\u002Fsynctest` is not yet covered by Go's compatibility guarantee. Its API may change in future releases. For stable alternatives, use `clockwork` (see [Mocking](.\u002Freferences\u002Fmocking.md)).\n\n`testing\u002Fsynctest` (Go 1.24+) provides deterministic time for concurrent code testing. Time advances only when all goroutines are blocked, making ordering predictable.\n\nWhen to use `synctest` instead of real time:\n\n- Testing concurrent code with time-based operations (time.Sleep, time.After, time.Ticker)\n- When race conditions need to be reproducible\n- When tests are flaky due to timing issues\n\n```go\nimport (\n    \"testing\"\n    \"time\"\n    \"testing\u002Fsynctest\"\n    \"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n)\n\nfunc TestChannelTimeout(t *testing.T) {\n    synctest.Run(func(t *testing.T) {\n        is := assert.New(t)\n\n        ch := make(chan int, 1)\n        go func() {\n            time.Sleep(50 * time.Millisecond)\n            ch \u003C- 42\n        }()\n\n        select {\n        case v := \u003C-ch:\n            is.Equal(42, v)\n        case \u003C-time.After(100 * time.Millisecond):\n            t.Fatal(\"timeout occurred\")\n        }\n    })\n}\n```\n\nKey differences in `synctest`:\n\n- `time.Sleep` advances synthetic time instantly when the goroutine blocks\n- `time.After` fires when synthetic time reaches the duration\n- All goroutines run to blocking points before time advances\n- Test execution is deterministic and repeatable\n\n## Test Timeouts\n\nFor tests that may hang, use a timeout helper that panics with caller location. See [Helpers](.\u002Freferences\u002Fhelpers.md).\n\n## Benchmarks\n\n→ See `samber\u002Fcc-skills-golang@golang-benchmark` skill for advanced benchmarking: `b.Loop()` (Go 1.24+), `benchstat`, profiling from benchmarks, and CI regression detection.\n\nWrite benchmarks to measure performance and detect regressions:\n\n```go\nfunc BenchmarkStringConcatenation(b *testing.B) {\n    b.Run(\"plus-operator\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            result := \"a\" + \"b\" + \"c\"\n            _ = result\n        }\n    })\n\n    b.Run(\"strings.Builder\", func(b *testing.B) {\n        for i := 0; i \u003C b.N; i++ {\n            var builder strings.Builder\n            builder.WriteString(\"a\")\n            builder.WriteString(\"b\")\n            builder.WriteString(\"c\")\n            _ = builder.String()\n        }\n    })\n}\n```\n\nBenchmarks with different input sizes:\n\n```go\nfunc BenchmarkFibonacci(b *testing.B) {\n    sizes := []int{10, 20, 30}\n    for _, size := range sizes {\n        b.Run(fmt.Sprintf(\"n=%d\", size), func(b *testing.B) {\n            b.ReportAllocs()\n            for i := 0; i \u003C b.N; i++ {\n                Fibonacci(size)\n            }\n        })\n    }\n}\n```\n\n## Parallel Tests\n\nUse `t.Parallel()` to run tests concurrently:\n\n```go\nfunc TestParallelOperations(t *testing.T) {\n    tests := []struct {\n        name string\n        data []byte\n    }{\n        {\"small data\", make([]byte, 1024)},\n        {\"medium data\", make([]byte, 1024*1024)},\n    }\n\n    for _, tt := range tests {\n        t.Run(tt.name, func(t *testing.T) {\n            t.Parallel()\n            is := assert.New(t)\n\n            result := Process(tt.data)\n            is.NotNil(result)\n        })\n    }\n}\n```\n\n## Fuzzing\n\nUse fuzzing to find edge cases and bugs:\n\n```go\nfunc FuzzReverse(f *testing.F) {\n    f.Add(\"hello\")\n    f.Add(\"\")\n    f.Add(\"a\")\n\n    f.Fuzz(func(t *testing.T, input string) {\n        reversed := Reverse(input)\n        doubleReversed := Reverse(reversed)\n        if input != doubleReversed {\n            t.Errorf(\"Reverse(Reverse(%q)) = %q, want %q\", input, doubleReversed, input)\n        }\n    })\n}\n```\n\n## Examples as Documentation\n\nExamples are executable documentation verified by `go test`:\n\n```go\nfunc ExampleCalculatePrice() {\n    price := CalculatePrice(100, 10.0)\n    fmt.Printf(\"Price: %.2f\\n\", price)\n    \u002F\u002F Output: Price: 900.00\n}\n\nfunc ExampleCalculatePrice_singleItem() {\n    price := CalculatePrice(1, 25.50)\n    fmt.Printf(\"Price: %.2f\\n\", price)\n    \u002F\u002F Output: Price: 25.50\n}\n```\n\n## Code Coverage\n\n```bash\n# Generate coverage file\ngo test -coverprofile=coverage.out .\u002F...\n\n# View coverage in HTML\ngo tool cover -html=coverage.out\n\n# Coverage by function\ngo tool cover -func=coverage.out\n\n# Total coverage percentage\ngo tool cover -func=coverage.out | grep total\n```\n\n## Integration Tests\n\nUse build tags to separate integration tests from unit tests:\n\n```go\n\u002F\u002Fgo:build integration\n\npackage mypackage\n\nfunc TestDatabaseIntegration(t *testing.T) {\n    db, err := sql.Open(\"postgres\", os.Getenv(\"DATABASE_URL\"))\n    if err != nil {\n        t.Fatal(err)\n    }\n    defer db.Close()\n\n    \u002F\u002F Test real database operations\n}\n```\n\nRun integration tests separately:\n\n```bash\ngo test -tags=integration .\u002F...\n```\n\nFor Docker Compose fixtures, SQL schemas, and integration test suites, see [Integration Testing](.\u002Freferences\u002Fintegration-testing.md).\n\n## Mocking\n\nMock interfaces, not concrete types. Define interfaces where consumed, then create mock implementations.\n\nFor mock patterns, test fixtures, and time mocking, see [Mocking](.\u002Freferences\u002Fmocking.md).\n\n## Enforce with Linters\n\nMany test best practices are enforced automatically by linters: `thelper`, `paralleltest`, `testifylint`. See the `samber\u002Fcc-skills-golang@golang-linter` skill for configuration and usage.\n\n## Cross-References\n\n- -> See `samber\u002Fcc-skills-golang@golang-stretchr-testify` skill for detailed testify API (assert, require, mock, suite)\n- -> See `samber\u002Fcc-skills-golang@golang-database` skill (testing.md) for database integration test patterns\n- -> See `samber\u002Fcc-skills-golang@golang-concurrency` skill for goroutine leak detection with goleak\n- -> See `samber\u002Fcc-skills-golang@golang-continuous-integration` skill for CI test configuration and GitHub Actions workflows\n- -> See `samber\u002Fcc-skills-golang@golang-linter` skill for testifylint and paralleltest configuration\n\n## Quick Reference\n\n```bash\ngo test .\u002F...                          # all tests\ngo test -run TestName .\u002F...            # specific test by exact name\ngo test -run TestName\u002Fsubtest .\u002F...    # subtests within a test\ngo test -run 'Test(Add|Sub)' .\u002F...     # multiple tests (regexp OR)\ngo test -run 'Test[A-Z]' .\u002F...         # tests starting with capital letter\ngo test -run 'TestUser.*' .\u002F...        # tests matching prefix\ngo test -run '.*Validation.*' .\u002F...    # tests containing substring\ngo test -run TestName\u002F. .\u002F...          # all subtests of TestName\ngo test -run '\u002F(unit|integration)' .\u002F... # filter by subtest name\ngo test -race .\u002F...                    # race detection\ngo test -cover .\u002F...                   # coverage summary\ngo test -bench=. -benchmem .\u002F...       # benchmarks\ngo test -fuzz=FuzzName .\u002F...           # fuzzing\ngo test -tags=integration .\u002F...        # integration tests\n```\n",{"name":5,"license":15,"metadata":54,"description":7,"allowed-tools":57,"compatibility":58,"user-invocable":59},{"author":55,"version":56},"samber","1.1.2","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent Bash(gotests:*) AskUserQuestion","Designed for Claude Code or similar AI coding agents, and for projects using Golang.",true,"master","b4819add93efbaf4d80627118ec34680406b309b","packages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing",1,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats","https:\u002F\u002Fgithub.com\u002Fmuratovv","2026-11-05 20:59:10",{"source":8,"skillName":5,"commands":68,"prompt":78,"zipAvailable":59},[69,72,75],{"tool":70,"command":71},"npx","npx skills add muratovv\u002Fai-hats --skill golang-testing",{"tool":73,"command":74},"bunx","bunx skills add muratovv\u002Fai-hats --skill golang-testing",{"tool":76,"command":77},"pnpm","pnpm dlx skills add muratovv\u002Fai-hats --skill golang-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002FSKILL.md",[80,86,91,95,99,103,107],{"path":81,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"evals\u002Fevals.json","REFERENCE","参考文档",18189,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002Fevals\u002Fevals.json",{"path":87,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":89,"sourceHtmlUrl":90},"LICENSE","许可证",1070,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002FLICENSE",{"path":92,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":93,"sourceHtmlUrl":94},"metadata.yaml",639,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002Fmetadata.yaml",{"path":96,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":97,"sourceHtmlUrl":98},"references\u002Fhelpers.md",1054,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002Freferences\u002Fhelpers.md",{"path":100,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":101,"sourceHtmlUrl":102},"references\u002Fhttp-testing.md",2268,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002Freferences\u002Fhttp-testing.md",{"path":104,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":105,"sourceHtmlUrl":106},"references\u002Fintegration-testing.md",4166,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002Freferences\u002Fintegration-testing.md",{"path":108,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":109,"sourceHtmlUrl":110},"references\u002Fmocking.md",4573,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-testing\u002Freferences\u002Fmocking.md",[112,137,162,183,207,221],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":49},"01M6PVFB1SM738R2SRSRSF7CY6","tool-evaluation-protocol","Time-bounded protocol for evaluating new tools, libraries, or methodologies before adoption. Use when evaluating a candidate dependency for the project, researching a methodology (e.g. ML\u002FLLM frameworks, testing approaches), or following up on a hype-driven recommendation.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Ftool-evaluation-protocol\u002FSKILL.md",[],[119,120,121,122,30,123,124,125,126,127,128,129,36,130,131,132,133,134,135,136],"protocol","Evaluation","tool","tool evaluation protocol","ml","libraries","adoption","methodology","Tools","use","dependency","frameworks","time","project","recommendation","for","bounded","candidate",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":49},"01M6PVF7HATBEX1G7N50E2QT57","systematic-debugging","4-phase bug-fix protocol (evidence, pattern, hypothesis, verify). Use when investigating any error, failure, or unexpected behavior, handling bug reports from users or monitoring, or diagnosing test failures with non-obvious causes.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[144,145,146,147,119,148,149,150,151,152,128,153,154,155,156,157,158,159,160,161],"systematic debugging","debugging","systematic","test","monitoring","hypothesis","verify","behavior","fix","evidence","bug","reports","pattern","users","error","with","bug-fix","phase",{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":171,"publishedAt":49},"01M6PVF3MTQN3RPF73AN34856J","skill-template","Canonical template and validation guide for ai-hats skills. Use when creating a new skill, reviewing an existing one for structural compliance, or deciding which pattern fits a new behavior.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fskill-template\u002FSKILL.md",[168],{"categoryNo":169,"categoryName":170,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[172,173,174,175,176,151,177,128,178,156,179,180,181,134,182],"template","skill template","validation","compliance","hats","guide","new skill","structural","canonical","which","Existing",{"skillNo":184,"name":185,"nameZh":6,"description":186,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":187,"categories":188,"keywords":190,"publishedAt":49},"01M6PVF06SCV28QARM5MQPANC9","skill-optimization","Audit and refactor library components to eliminate redundancy and staleness. Use during periodic library maintenance, after adding multiple new skills or rules, when a role's token budget is too high, or after retrospectives identify component issues.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fskill-optimization\u002FSKILL.md",[189],{"categoryNo":169,"categoryName":170,"taxonomyType":21,"taxonomyTypeDesc":22},[191,192,193,194,195,196,197,198,199,200,128,201,202,203,204,205,206],"Optimization","skill optimization","components","component","issues","library","audit","refactor","Budget","Rules","periodic","maintenance","token","token budget","role","high",{"skillNo":208,"name":209,"nameZh":6,"description":210,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":211,"categories":212,"keywords":213,"publishedAt":49},"01M6PVEXM9717016T9MW82HDCT","silent-fallback-gate","PreToolUse hook — refuses an Edit or Write that adds an inert broad except. Use when a Python edit was blocked for a silent fallback.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fsilent-fallback-gate\u002FSKILL.md",[],[214,215,216,217,218,219,128,220,134],"gate","fallback","silent fallback gate","python","write","edit","hook",{"skillNo":222,"name":223,"nameZh":6,"description":224,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":225,"categories":226,"keywords":228,"publishedAt":49},"01M6PVESM49C5NT7SB7N3F76VS","retro-to-framework","Convert an observation about agent behavior — from a retrospective or from a single incident — into a framework-level change (hook, rule, skill, skill update). Use after a retrospective identifies problems that are not project-specific, after an incident where an agent misapplied a component it had read, when CLAUDE.md band-aids accumulate (more than 3 per-project rules that could be generic), or when the same problem recurs across multiple projects.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fretro-to-framework\u002FSKILL.md",[227],{"categoryNo":169,"categoryName":170,"taxonomyType":21,"taxonomyTypeDesc":22},[229,230,231,232,194,233,40,234,200,151,128,235,236,132,237,238,239,240,241,242],"framework","retro","retro to framework","change","retrospective","convert","incident","across","problem","about","more","skill update","single","generic"]