[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BQC8NKZZPKHT3SFBJR4N7F":3,"skill-same:01M7BQC8NKZZPKHT3SFBJR4N7F":51},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7BQC8NKZZPKHT3SFBJR4N7F","go-data-structures",null,"Use when creating or manipulating Go slices, maps, arrays, or sets, including new\u002Fmake, append, copies, and nil versus empty JSON collections. Thread safety belongs to go-concurrency.","h0rn3t\u002Fgolang-skills","h0rn3t","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1213719?v=4","01M7BQBDJ8D4P5W7EQHBD464BX","Eugene Shershen","01M7BQBDJXMTCKNCEDKVEYDRGA",7,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-data-structures\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-data-structures\ndescription: Use when creating or manipulating Go slices, maps, arrays, or sets, including new\u002Fmake, append, copies, and nil versus empty JSON collections. Thread safety belongs to go-concurrency.\n---\n\n# Go Data Structures\n\n> Compatibility: Baseline Go 1.27 (see [COMPATIBILITY.md](..\u002Fgo-style-core\u002Freferences\u002FCOMPATIBILITY.md)). `slices`\u002F`maps`\n> and `slices.Clone`\u002F`maps.Clone` require Go 1.21+; `slices.Concat` Go 1.22+;\n> `strings.CutLast`\u002F`bytes.CutLast` Go 1.27+.\n\n## Resource Routing\n\n- `references\u002FSLICES.md` - Read when managing slice capacity and aliasing, or when a subslice keeps a large backing array alive.\n\n## Slices\n\n### Reach for `slices` and `maps` First\n\nThe `slices` and `maps` packages (Go 1.21+) cover most hand-written loops.\nWriting the loop instead is a reviewable defect, not a style choice.\n`go fix -diff` on the edited package previews the loops a fixer exists for\n(`slicescontains`, `slicesbackward`, `slicessort`, `mapsloop`, `minmax`);\n`Equal`, `Concat`, `Insert`, and `Delete` have none: replace those loops\nyourself.\n\n| Loop you were about to write | Use |\n|---|---|\n| Compare | `slices.Equal`, `maps.Equal` |\n| Concatenate | `slices.Concat` (Go 1.22+) |\n| Insert\u002Fdelete in the middle | `slices.Insert`, `slices.Delete` |\n| Iterate in reverse | `slices.Backward` (Go 1.23+) |\n| Split off the last segment | `strings.CutLast` \u002F `bytes.CutLast` (Go 1.27+) |\n\n```go\nns, name, ok := strings.CutLast(key, \".\") \u002F\u002F \"app.http.requests\" → \"app.http\", \"requests\", true\nif !ok {\n    ns, name = \"\", key \u002F\u002F no \".\": CutLast returned key, \"\", false\n}\n```\n\n`slices.Clone` and `maps.Clone` preserve nilness: nil input yields nil, while\nan initialized empty container stays non-nil. `slices.Collect`,\n`slices.Sorted`, and `slices.Concat` return nil for an empty result —\n`Concat` even when every input is a non-nil empty slice. An unconditional\n`make` plus copy produces a non-nil container even for nil input. Preserve\nthat allocation when JSON, a later map write, or observable capacity requires\nit — see [Declaring Empty Slices](#declaring-empty-slices). Check the contract\nbefore replacing a loop:\n\n```go\nall := slices.Concat(a, b)\nif all == nil {\n    all = []Item{} \u002F\u002F encoding\u002Fjson v1 writes nil as null; this list's contract is []\n}\n```\n\nThese clones are shallow: references inside elements or map values remain\nshared. Copy depth and type-specific `Clone` contracts belong to\n[go-defensive](..\u002Fgo-defensive\u002Freferences\u002FBOUNDARY-COPYING.md#copy-depth-is-part-of-the-contract).\n\n### Update and Filter an Existing Map\n\nWhen updates must overwrite matching keys before filtering the resulting map:\n\n```go\nmaps.Copy(dst, updates)\nmaps.DeleteFunc(dst, func(_ string, score int) bool { return score \u003C minimum })\n```\n\nBoth operations mutate `dst`, so existing aliases observe the changes.\nThe destination must be initialized if the source contains entries.\n\n### Declaring Empty Slices\n\nPrefer nil slices over empty literals:\n\n```go\n\u002F\u002F Good: nil slice\nvar t []string\n\n\u002F\u002F Avoid: non-nil but zero-length\nt := []string{}\n```\n\nBoth have `len` and `cap` of zero, but the nil slice is the preferred style.\n\n**JSON depends on the encoder**: `encoding\u002Fjson` v1 encodes a nil slice or\nnil map as `null`, and `[]string{}` as `[]`, `map[string]int{}` as `{}`. JSON\nv2 defaults encode nil non-byte slices as `[]` and nil maps as `{}`;\n`FormatNilSliceAsNull(true)` and `FormatNilMapAsNull(true)` restore null.\nRequire non-nil only when the selected encoder\u002Foptions or another caller\ncontract needs it. See\n[JSON v2 defaults](..\u002Fgo-http\u002Freferences\u002FJSON-V2.md#defaults-that-can-change-the-contract).\n\nWhen designing interfaces, avoid distinguishing between nil and non-nil\nzero-length slices.\n\n---\n\n## Maps\n\n### Implementing a Set\n\nUse `map[T]struct{}` when the map is only a set. The empty struct takes no\nstorage and makes membership intent explicit.\n\nUse boolean map values only when the value carries a separate meaning beyond\npresence.\n\n### A Map Never Shrinks\n\n`delete` and `clear` free the values but keep the table at its peak size\n(measured on Go 1.27: 500K keys at 30 MiB stay at 26 MiB after either). A map\nwhose size swings — per-window counters, a swept cache, a limiter reset — is\nreset by assigning a fresh `make`, and the old one is collected.\n\n---\n\n## Copying\n\nA struct whose methods have pointer receivers or that holds a lock\n(`bytes.Buffer`, `sync.Mutex`) is passed by pointer, never copied — except a\nvalue type whose only pointer methods are decoders, such as `time.Time`;\n[go-functions](..\u002Fgo-functions\u002FSKILL.md#pointers-to-interfaces) owns the rule.\n\n---\n\n## Related Skills\n\n- [go-defensive](..\u002Fgo-defensive\u002FSKILL.md): copying slices and maps at API boundaries.\n- [go-performance](..\u002Fgo-performance\u002FSKILL.md): capacity hints for known workloads.\n- [go-style-core](..\u002Fgo-style-core\u002FSKILL.md): range forms and `new`\u002F`make`\u002F`var`\u002Fliteral choices.\n","# Go Data Structures\n\n> Compatibility: Baseline Go 1.27 (see [COMPATIBILITY.md](..\u002Fgo-style-core\u002Freferences\u002FCOMPATIBILITY.md)). `slices`\u002F`maps`\n> and `slices.Clone`\u002F`maps.Clone` require Go 1.21+; `slices.Concat` Go 1.22+;\n> `strings.CutLast`\u002F`bytes.CutLast` Go 1.27+.\n\n## Resource Routing\n\n- `references\u002FSLICES.md` - Read when managing slice capacity and aliasing, or when a subslice keeps a large backing array alive.\n\n## Slices\n\n### Reach for `slices` and `maps` First\n\nThe `slices` and `maps` packages (Go 1.21+) cover most hand-written loops.\nWriting the loop instead is a reviewable defect, not a style choice.\n`go fix -diff` on the edited package previews the loops a fixer exists for\n(`slicescontains`, `slicesbackward`, `slicessort`, `mapsloop`, `minmax`);\n`Equal`, `Concat`, `Insert`, and `Delete` have none: replace those loops\nyourself.\n\n| Loop you were about to write | Use |\n|---|---|\n| Compare | `slices.Equal`, `maps.Equal` |\n| Concatenate | `slices.Concat` (Go 1.22+) |\n| Insert\u002Fdelete in the middle | `slices.Insert`, `slices.Delete` |\n| Iterate in reverse | `slices.Backward` (Go 1.23+) |\n| Split off the last segment | `strings.CutLast` \u002F `bytes.CutLast` (Go 1.27+) |\n\n```go\nns, name, ok := strings.CutLast(key, \".\") \u002F\u002F \"app.http.requests\" → \"app.http\", \"requests\", true\nif !ok {\n    ns, name = \"\", key \u002F\u002F no \".\": CutLast returned key, \"\", false\n}\n```\n\n`slices.Clone` and `maps.Clone` preserve nilness: nil input yields nil, while\nan initialized empty container stays non-nil. `slices.Collect`,\n`slices.Sorted`, and `slices.Concat` return nil for an empty result —\n`Concat` even when every input is a non-nil empty slice. An unconditional\n`make` plus copy produces a non-nil container even for nil input. Preserve\nthat allocation when JSON, a later map write, or observable capacity requires\nit — see [Declaring Empty Slices](#declaring-empty-slices). Check the contract\nbefore replacing a loop:\n\n```go\nall := slices.Concat(a, b)\nif all == nil {\n    all = []Item{} \u002F\u002F encoding\u002Fjson v1 writes nil as null; this list's contract is []\n}\n```\n\nThese clones are shallow: references inside elements or map values remain\nshared. Copy depth and type-specific `Clone` contracts belong to\n[go-defensive](..\u002Fgo-defensive\u002Freferences\u002FBOUNDARY-COPYING.md#copy-depth-is-part-of-the-contract).\n\n### Update and Filter an Existing Map\n\nWhen updates must overwrite matching keys before filtering the resulting map:\n\n```go\nmaps.Copy(dst, updates)\nmaps.DeleteFunc(dst, func(_ string, score int) bool { return score \u003C minimum })\n```\n\nBoth operations mutate `dst`, so existing aliases observe the changes.\nThe destination must be initialized if the source contains entries.\n\n### Declaring Empty Slices\n\nPrefer nil slices over empty literals:\n\n```go\n\u002F\u002F Good: nil slice\nvar t []string\n\n\u002F\u002F Avoid: non-nil but zero-length\nt := []string{}\n```\n\nBoth have `len` and `cap` of zero, but the nil slice is the preferred style.\n\n**JSON depends on the encoder**: `encoding\u002Fjson` v1 encodes a nil slice or\nnil map as `null`, and `[]string{}` as `[]`, `map[string]int{}` as `{}`. JSON\nv2 defaults encode nil non-byte slices as `[]` and nil maps as `{}`;\n`FormatNilSliceAsNull(true)` and `FormatNilMapAsNull(true)` restore null.\nRequire non-nil only when the selected encoder\u002Foptions or another caller\ncontract needs it. See\n[JSON v2 defaults](..\u002Fgo-http\u002Freferences\u002FJSON-V2.md#defaults-that-can-change-the-contract).\n\nWhen designing interfaces, avoid distinguishing between nil and non-nil\nzero-length slices.\n\n---\n\n## Maps\n\n### Implementing a Set\n\nUse `map[T]struct{}` when the map is only a set. The empty struct takes no\nstorage and makes membership intent explicit.\n\nUse boolean map values only when the value carries a separate meaning beyond\npresence.\n\n### A Map Never Shrinks\n\n`delete` and `clear` free the values but keep the table at its peak size\n(measured on Go 1.27: 500K keys at 30 MiB stay at 26 MiB after either). A map\nwhose size swings — per-window counters, a swept cache, a limiter reset — is\nreset by assigning a fresh `make`, and the old one is collected.\n\n---\n\n## Copying\n\nA struct whose methods have pointer receivers or that holds a lock\n(`bytes.Buffer`, `sync.Mutex`) is passed by pointer, never copied — except a\nvalue type whose only pointer methods are decoders, such as `time.Time`;\n[go-functions](..\u002Fgo-functions\u002FSKILL.md#pointers-to-interfaces) owns the rule.\n\n---\n\n## Related Skills\n\n- [go-defensive](..\u002Fgo-defensive\u002FSKILL.md): copying slices and maps at API boundaries.\n- [go-performance](..\u002Fgo-performance\u002FSKILL.md): capacity hints for known workloads.\n- [go-style-core](..\u002Fgo-style-core\u002FSKILL.md): range forms and `new`\u002F`make`\u002F`var`\u002Fliteral choices.\n",{"name":5,"description":7},"main","59ac8ac7a0dd394878aaa0a7a7ecbc227356739f","skills\u002Fgo-data-structures",2,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills","https:\u002F\u002Fgithub.com\u002Fh0rn3t","2026-11-14 04:23:12",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add h0rn3t\u002Fgolang-skills --skill go-data-structures",{"tool":37,"command":38},"bunx","bunx skills add h0rn3t\u002Fgolang-skills --skill go-data-structures",{"tool":40,"command":41},"pnpm","pnpm dlx skills add h0rn3t\u002Fgolang-skills --skill go-data-structures","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-data-structures\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002FSLICES.md","REFERENCE","参考文档",1104,"https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-data-structures\u002Freferences\u002FSLICES.md",[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7BQEMJBPJWY6CCGVKW27SH0","go-troubleshooting","Use when investigating a bug or ticket in a Go service whose cause is unknown — wrong or missing results, tenant-specific behavior, a regression, stage\u002Fprod\u002FCI differences, a panic, hang, deadlock, leak, unexplained CPU\u002FRSS growth, or a flaky test. Also use for pasted stack traces, profiles, logs, or requests to find a Go issue's root cause, even without the word debug. Does not cover rewriting ticket text, implementing an already-diagnosed fix alone (use its topic skill), or optimizing a known bottleneck (see go-performance).","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-troubleshooting\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7BQEFVSRHNDND750SB69WD8","go-testing","Use when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff. Also use when a user asks to write a test for a Go function, even if they don't mention specific patterns like table-driven tests or subtests. Does not cover benchmark performance testing (see go-performance).","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-testing\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7BQEA2DRH6H6WFYNJYJJRQQ","go-style-core","Use when resolving Go style or language mechanics such as formatting, nesting, declarations, initialization, scope, shadowing, loops, switches, or enum zero values. API design, naming, errors, and tests have specialized skills.","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-style-core\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7BQE3D1H45ANCXAWCS55CDK","go-security","Use when writing or reviewing Go code that touches untrusted input, secrets, or credentials — SQL, shell, or template injection, path traversal, SSRF, cookies and security headers, password hashing, TLS settings, token comparison, or what may appear in a log line. Also use when a handler accepts a file name, URL, or command argument from a client, or when asked to find \"vulnerabilities\", even if the user never says \"security\". Does not cover the os.Root and crypto\u002Frand mechanics (see go-defensive) or the dependency CVE scan in the gate (see go-linting).","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-security\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7BQDZYHG2YRJA3J26HFPKR7","go-resilience","Use when handling Go dependency failures or overload with retries, backoff\u002Fjitter, budgets, idempotency, duplicate delivery, circuit breakers, bulkheads, rate limits, backpressure, or degradation. Unknown root causes belong to go-troubleshooting.","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-resilience\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7BQDVG7DH2G9Z97Y8H3P3E9","go-performance","Use when optimizing slow or performance-critical Go code, allocations, string concatenation in loops, or benchmarks. Also use when writing or reviewing a cache, including implementing one from a stub — its key, its expiry, and how a miss loads. Concurrent code patterns belong to go-concurrency.","https:\u002F\u002Fgithub.com\u002Fh0rn3t\u002Fgolang-skills\u002Fblob\u002Fmain\u002Fskills\u002Fgo-performance\u002FSKILL.md",[],[]]