[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79Z8YR9FJES9BCENCJ2HWFX":3,"skill-same:01M79Z8YR9FJES9BCENCJ2HWFX":52},{"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":31,"commitSha":32,"skillDirectory":33,"forksCount":14,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":36,"ownerDescription":37,"updatedAt":38,"install":39,"resources":51},"01M79Z8YR9FJES9BCENCJ2HWFX","go-data-structures",null,"Correct use of Go's built-in data structures: slices (nil vs empty, append semantics, aliasing, preallocation), maps (comma-ok, sets, iteration order), arrays, and choosing between them. Use when: \"slice vs array\", \"nil slice\", \"empty slice\", \"preallocate\", \"map iteration\", \"use a set in Go\", \"slice aliasing\", \"append gotcha\", \"copy a slice\", \"sync.Map or mutex\". Not for: structures shared across goroutines (go-concurrency-review), allocation profiling (go-performance-review), generic containers (go-design-patterns).","kongnakornna\u002Fgolangapi","kongnakornna","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10528904?v=4","01M79Z5JQPPV5CWQHXS235Q9MD","Kongnakorn Jantakun","01M79Z5JRHJJJ6PR2DGQS4P985",0,"MIT","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(code-quality)\u002Fgo-data-structures\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-data-structures\ndescription: >\n  Correct use of Go's built-in data structures: slices (nil vs empty, append\n  semantics, aliasing, preallocation), maps (comma-ok, sets, iteration\n  order), arrays, and choosing between them. Use when: \"slice vs array\",\n  \"nil slice\", \"empty slice\", \"preallocate\", \"map iteration\", \"use a set in\n  Go\", \"slice aliasing\", \"append gotcha\", \"copy a slice\", \"sync.Map or\n  mutex\".\n  Not for: structures shared across goroutines (go-concurrency-review),\n  allocation profiling (go-performance-review), generic containers\n  (go-design-patterns).\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain.\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)\nmetadata:\n  author: eduardo-sl\n  version: \"1.1.1\"\n---\n\n# Go Data Structures\n\nSlices and maps look simple and hide the sharpest edges in the language.\nThese rules prevent the aliasing, nil, and iteration bugs that survive\ncode review.\n\n## 1. Nil Slice vs Empty Slice\n\n```go\nvar a []int          \u002F\u002F nil slice — len 0, cap 0, no allocation\nb := []int{}         \u002F\u002F empty slice — len 0, allocated header\nc := make([]int, 0)  \u002F\u002F empty slice — same as b\n```\n\n- `len`, `cap`, `range`, and `append` treat all three identically.\n- **Prefer the nil slice** as the \"no elements\" value; don't allocate\n  just to return \"empty\".\n- Exception: JSON. `nil` marshals to `null`, empty marshals to `[]`.\n  If the API contract requires `[]`, return an empty slice explicitly.\n- Never distinguish nil from empty in logic — check `len(s) == 0`.\n\n## 2. Append Semantics and Aliasing\n\n`append` MAY return the same backing array or a new one. Both cases\nbite:\n\n```go\n\u002F\u002F ❌ Bad — result may alias the input\nfunc addSuffix(base []string) []string {\n    return append(base, \"suffix\") \u002F\u002F if cap(base) > len(base),\n}                                 \u002F\u002F this WRITES INTO base's array\n\n\u002F\u002F ✅ Good — force a copy when the input must not be touched\nfunc addSuffix(base []string) []string {\n    out := make([]string, len(base), len(base)+1)\n    copy(out, base)\n    return append(out, \"suffix\")\n}\n```\n\n```go\n\u002F\u002F ❌ Bad — subslice keeps the whole 64 MB alive\nfunc header(big []byte) []byte {\n    return big[:512] \u002F\u002F backing array is still the full big\n}\n\n\u002F\u002F ✅ Good — copy the window you keep\nfunc header(big []byte) []byte {\n    return slices.Clone(big[:512]) \u002F\u002F Go 1.21+; or copy() manually\n}\n```\n\nRule: a function either owns a slice or copies it. Returning a subslice\nof a caller's slice, or appending to one, silently shares memory.\n\n## 3. Preallocation\n\nWhen the final size is known or bounded, allocate once:\n\n```go\n\u002F\u002F ✅ Good — one allocation\nnames := make([]string, 0, len(users))\nfor _, u := range users {\n    names = append(names, u.Name)\n}\n\n\u002F\u002F ❌ Bad — repeated growth and copying\nvar names []string\nfor _, u := range users {\n    names = append(names, u.Name)\n}\n```\n\nSame for maps: `make(map[string]int, len(items))`.\nDon't preallocate when the size is unknown — a wrong large cap wastes\nmemory; `append` growth is fine for cold paths.\n\n## 4. Map Essentials\n\n```go\n\u002F\u002F Comma-ok distinguishes \"missing\" from \"zero value\"\ncount, ok := hits[key]\nif !ok { \u002F* key absent *\u002F }\n\n\u002F\u002F Zero value reads are safe; writes to a nil map PANIC\nvar m map[string]int\n_ = m[\"x\"]      \u002F\u002F 0, fine\nm[\"x\"] = 1      \u002F\u002F panic: assignment to entry in nil map — make() first\n\n\u002F\u002F Iteration order is RANDOM and differs between runs.\n\u002F\u002F Sort keys when output must be deterministic:\nkeys := slices.Sorted(maps.Keys(m)) \u002F\u002F Go 1.23+\nfor _, k := range keys {\n    fmt.Println(k, m[k])\n}\n```\n\n- Map values are not addressable: `m[k].Field = v` doesn't compile for\n  struct values. Use a map of pointers, or read-modify-write.\n- Deleting during `range` is safe; inserting during `range` is\n  unspecified (the new key may or may not be visited).\n\n## 5. Sets\n\nThe idiomatic set is a map with empty-struct values:\n\n```go\nseen := make(map[string]struct{}, len(items))\nfor _, it := range items {\n    if _, dup := seen[it.ID]; dup {\n        continue\n    }\n    seen[it.ID] = struct{}{}\n    process(it)\n}\n```\n\n`struct{}` occupies zero bytes; `map[string]bool` also works and reads\nbetter when you'll test membership with `if seen[id]`.\n\n## 6. Arrays vs Slices\n\n- Arrays (`[4]byte`) are values: assignment and passing copy the whole\n  array. Comparable with `==` when elements are comparable.\n- Use arrays for fixed-size data with value semantics: hashes\n  (`[32]byte`), IPv4 addresses, fixed matrices, map keys.\n- Everything else is a slice. A function taking `[100]int` copies 800\n  bytes per call — almost always wrong.\n\n## 7. Choosing a Structure\n\n| Need | Use |\n|---|---|\n| Ordered collection, growable | `[]T` |\n| Membership \u002F dedup | `map[K]struct{}` |\n| Key→value lookup | `map[K]V` |\n| Fixed size, value semantics, comparable | `[N]T` array |\n| FIFO queue (single goroutine) | slice with head index, or `container\u002Flist` for heavy churn |\n| Stack | slice + `append` \u002F `s[:len(s)-1]` |\n| Concurrent map, write-once read-many keys | `sync.Map` — otherwise mutex + map |\n\n`sync.Map` is a special-case tool (append-only caches, disjoint key\nsets). Default to `map` + `sync.RWMutex`; see the concurrency skill for\nlocking patterns.\n\n## Verification Checklist\n\n1. No logic distinguishes nil slice from empty slice; `len()` used for emptiness\n2. JSON-facing slices explicitly empty (not nil) where the contract requires `[]`\n3. No `append` to a slice the function doesn't own; copies made explicit\n4. No long-lived subslices of large arrays without `slices.Clone`\u002F`copy`\n5. Slices and maps preallocated with capacity when size is known\n6. Comma-ok used wherever \"missing\" differs from zero value\n7. No writes to possibly-nil maps\n8. Deterministic output paths sort map keys before iteration\n9. Sets built as `map[K]struct{}` (or `map[K]bool` for readability)\n10. Arrays only where value semantics or comparability is the point\n","# Go Data Structures\n\nSlices and maps look simple and hide the sharpest edges in the language.\nThese rules prevent the aliasing, nil, and iteration bugs that survive\ncode review.\n\n## 1. Nil Slice vs Empty Slice\n\n```go\nvar a []int          \u002F\u002F nil slice — len 0, cap 0, no allocation\nb := []int{}         \u002F\u002F empty slice — len 0, allocated header\nc := make([]int, 0)  \u002F\u002F empty slice — same as b\n```\n\n- `len`, `cap`, `range`, and `append` treat all three identically.\n- **Prefer the nil slice** as the \"no elements\" value; don't allocate\n  just to return \"empty\".\n- Exception: JSON. `nil` marshals to `null`, empty marshals to `[]`.\n  If the API contract requires `[]`, return an empty slice explicitly.\n- Never distinguish nil from empty in logic — check `len(s) == 0`.\n\n## 2. Append Semantics and Aliasing\n\n`append` MAY return the same backing array or a new one. Both cases\nbite:\n\n```go\n\u002F\u002F ❌ Bad — result may alias the input\nfunc addSuffix(base []string) []string {\n    return append(base, \"suffix\") \u002F\u002F if cap(base) > len(base),\n}                                 \u002F\u002F this WRITES INTO base's array\n\n\u002F\u002F ✅ Good — force a copy when the input must not be touched\nfunc addSuffix(base []string) []string {\n    out := make([]string, len(base), len(base)+1)\n    copy(out, base)\n    return append(out, \"suffix\")\n}\n```\n\n```go\n\u002F\u002F ❌ Bad — subslice keeps the whole 64 MB alive\nfunc header(big []byte) []byte {\n    return big[:512] \u002F\u002F backing array is still the full big\n}\n\n\u002F\u002F ✅ Good — copy the window you keep\nfunc header(big []byte) []byte {\n    return slices.Clone(big[:512]) \u002F\u002F Go 1.21+; or copy() manually\n}\n```\n\nRule: a function either owns a slice or copies it. Returning a subslice\nof a caller's slice, or appending to one, silently shares memory.\n\n## 3. Preallocation\n\nWhen the final size is known or bounded, allocate once:\n\n```go\n\u002F\u002F ✅ Good — one allocation\nnames := make([]string, 0, len(users))\nfor _, u := range users {\n    names = append(names, u.Name)\n}\n\n\u002F\u002F ❌ Bad — repeated growth and copying\nvar names []string\nfor _, u := range users {\n    names = append(names, u.Name)\n}\n```\n\nSame for maps: `make(map[string]int, len(items))`.\nDon't preallocate when the size is unknown — a wrong large cap wastes\nmemory; `append` growth is fine for cold paths.\n\n## 4. Map Essentials\n\n```go\n\u002F\u002F Comma-ok distinguishes \"missing\" from \"zero value\"\ncount, ok := hits[key]\nif !ok { \u002F* key absent *\u002F }\n\n\u002F\u002F Zero value reads are safe; writes to a nil map PANIC\nvar m map[string]int\n_ = m[\"x\"]      \u002F\u002F 0, fine\nm[\"x\"] = 1      \u002F\u002F panic: assignment to entry in nil map — make() first\n\n\u002F\u002F Iteration order is RANDOM and differs between runs.\n\u002F\u002F Sort keys when output must be deterministic:\nkeys := slices.Sorted(maps.Keys(m)) \u002F\u002F Go 1.23+\nfor _, k := range keys {\n    fmt.Println(k, m[k])\n}\n```\n\n- Map values are not addressable: `m[k].Field = v` doesn't compile for\n  struct values. Use a map of pointers, or read-modify-write.\n- Deleting during `range` is safe; inserting during `range` is\n  unspecified (the new key may or may not be visited).\n\n## 5. Sets\n\nThe idiomatic set is a map with empty-struct values:\n\n```go\nseen := make(map[string]struct{}, len(items))\nfor _, it := range items {\n    if _, dup := seen[it.ID]; dup {\n        continue\n    }\n    seen[it.ID] = struct{}{}\n    process(it)\n}\n```\n\n`struct{}` occupies zero bytes; `map[string]bool` also works and reads\nbetter when you'll test membership with `if seen[id]`.\n\n## 6. Arrays vs Slices\n\n- Arrays (`[4]byte`) are values: assignment and passing copy the whole\n  array. Comparable with `==` when elements are comparable.\n- Use arrays for fixed-size data with value semantics: hashes\n  (`[32]byte`), IPv4 addresses, fixed matrices, map keys.\n- Everything else is a slice. A function taking `[100]int` copies 800\n  bytes per call — almost always wrong.\n\n## 7. Choosing a Structure\n\n| Need | Use |\n|---|---|\n| Ordered collection, growable | `[]T` |\n| Membership \u002F dedup | `map[K]struct{}` |\n| Key→value lookup | `map[K]V` |\n| Fixed size, value semantics, comparable | `[N]T` array |\n| FIFO queue (single goroutine) | slice with head index, or `container\u002Flist` for heavy churn |\n| Stack | slice + `append` \u002F `s[:len(s)-1]` |\n| Concurrent map, write-once read-many keys | `sync.Map` — otherwise mutex + map |\n\n`sync.Map` is a special-case tool (append-only caches, disjoint key\nsets). Default to `map` + `sync.RWMutex`; see the concurrency skill for\nlocking patterns.\n\n## Verification Checklist\n\n1. No logic distinguishes nil slice from empty slice; `len()` used for emptiness\n2. JSON-facing slices explicitly empty (not nil) where the contract requires `[]`\n3. No `append` to a slice the function doesn't own; copies made explicit\n4. No long-lived subslices of large arrays without `slices.Clone`\u002F`copy`\n5. Slices and maps preallocated with capacity when size is known\n6. Comma-ok used wherever \"missing\" differs from zero value\n7. No writes to possibly-nil maps\n8. Deterministic output paths sort map keys before iteration\n9. Sets built as `map[K]struct{}` (or `map[K]bool` for readability)\n10. Arrays only where value semantics or comparability is the point\n",{"name":5,"license":15,"metadata":24,"description":27,"allowed-tools":28,"compatibility":29,"user-invocable":30},{"author":25,"version":26},"eduardo-sl","1.1.1","Correct use of Go's built-in data structures: slices (nil vs empty, append semantics, aliasing, preallocation), maps (comma-ok, sets, iteration order), arrays, and choosing between them. Use when: \"slice vs array\", \"nil slice\", \"empty slice\", \"preallocate\", \"map iteration\", \"use a set in Go\", \"slice aliasing\", \"append gotcha\", \"copy a slice\", \"sync.Map or mutex\". Not for: structures shared across goroutines (go-concurrency-review), allocation profiling (go-performance-review), generic containers (go-design-patterns).\n","Read Edit Write Glob Grep Bash(go:*) Bash(gofmt:*)","Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain.",true,"main","19f4d52a98d557f3a645a2cfbbeb5bd54f28831d",".github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(code-quality)\u002Fgo-data-structures","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi","https:\u002F\u002Fgithub.com\u002Fkongnakornna","http:\u002F\u002Fcmoniot.trueddns.com:52160","Technical Skills and Expertise\r\nLanguages and Frameworks\r\nFrontend: HTML, JavaScript, TypeScript, React, Vue, Angular, Next.js\r\nBackend: Node.js,Python,Golang","2026-10-06 23:01:46",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":30},[41,44,47],{"tool":42,"command":43},"npx","npx skills add kongnakornna\u002Fgolangapi --skill go-data-structures",{"tool":45,"command":46},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill go-data-structures",{"tool":48,"command":49},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill go-data-structures","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgo-agent-skills\u002Fskills\u002F(code-quality)\u002Fgo-data-structures\u002FSKILL.md",[],[53,61,68,75,82,89],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7A0M9RJJ3383VEFYKABWV15","tb-writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-writing-plans\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7A0M4JKY4DEDRP1CBHT00WV","tb-using-git-worktrees","Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-using-git-worktrees\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7A0KZ5HRAQAAT2KXR6146Q7","tb-test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-test-driven-development\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7A0KW92W3F18E2MRP8H62P2","tb-subagent-driven-development","Use when executing implementation plans with independent tasks in the current session","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-subagent-driven-development\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7A0KKYQCHYYRHA5J5BAP24M","tb-scrutinize","Outsider-perspective end-to-end review of a plan, PR, or code change. First questions intent and whether a simpler\u002Fmore elegant approach would achieve the same goal, then traces the actual code path (not just the diff) to verify the change does what it claims. Output is concise, actionable, and every call carries its rationale. Trigger on \u002Ftb-scrutinize and proactively whenever the user asks to review, audit, sanity-check, or get a second opinion on a plan, PR, diff, design doc, or proposed code change.","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-scrutinize\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":57,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M7A0KFDR1V3RW7SW1XNHP82P","tb-requesting-code-review","Use when completing tasks, implementing major features, or before merging to verify work meets requirements","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-requesting-code-review\u002FSKILL.md",[],[]]