[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79ZWQQ2DWTHY3BABMH0X1HD":3,"skill-same:01M79ZWQQ2DWTHY3BABMH0X1HD":71},{"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":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M79ZWQQ2DWTHY3BABMH0X1HD","go-error-handling",null,"Use when writing Go code that returns, wraps, or handles errors — choosing between sentinel errors, custom types, and fmt.Errorf (%w vs %v), structuring error flow, or deciding whether to log or return. Also use when propagating errors across package boundaries or using errors.Is\u002FAs, even if the user doesn't ask about error strategy. Does not cover panic\u002Frecover patterns (see go-defensive).","kongnakornna\u002Fgolangapi","kongnakornna","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10528904?v=4","01M79Z5JQPPV5CWQHXS235Q9MD","Kongnakorn Jantakun","01M79Z5JRHJJJ6PR2DGQS4P985",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: go-error-handling\ndescription: Use when writing Go code that returns, wraps, or handles errors — choosing between sentinel errors, custom types, and fmt.Errorf (%w vs %v), structuring error flow, or deciding whether to log or return. Also use when propagating errors across package boundaries or using errors.Is\u002FAs, even if the user doesn't ask about error strategy. Does not cover panic\u002Frecover patterns (see go-defensive).\nallowed-tools: Bash(bash:*)\n---\n\n# Go Error Handling\n\n> Compatibility: `errors.Is`, `errors.As`, and `%w` wrapping require Go 1.13+; structured logging examples may use `log\u002Fslog` from Go 1.21+.\n\n## Resource Routing\n\n- `scripts\u002Fcheck-errors.sh` - Run when checking string-based error matching, bare error propagation, and log-and-return patterns.\n- `scripts\u002Fcheck-errors-ast.go` - Implementation helper invoked by `check-errors.sh`; patch this when changing error-flow analysis behavior.\n- `references\u002FERROR-FLOW.md` - Read when deciding where to handle, wrap, log, or return errors.\n- `references\u002FERROR-TYPES.md` - Read when choosing sentinel errors, typed errors, or opaque errors.\n- `references\u002FWRAPPING.md` - Read when choosing `%w` versus `%v` or crossing package boundaries.\n\nIn Go, [errors are values](https:\u002F\u002Fgo.dev\u002Fblog\u002Ferrors-are-values) — they are\ncreated by code and consumed by code.\n\n## Choosing an Error Strategy\n\n1. System boundary (RPC, IPC, storage)? → Wrap with `%v` to avoid leaking internals\n2. Caller needs to match specific conditions? → Sentinel or typed error, wrap with `%w`\n3. Caller just needs debugging context? → `fmt.Errorf(\"...: %w\", err)`\n4. Leaf function, no wrapping needed? → Return the error directly\n\n**Default**: wrap with `%w` and place it at the end of the format string.\n\n---\n\n## Core Rules\n\n### Never Return Concrete Error Types\n\n**Never return concrete error types from exported functions** — a concrete `nil`\npointer can become a non-nil interface:\n\n```go\n\u002F\u002F Bad: Concrete type can cause subtle bugs\nfunc Bad() *os.PathError { \u002F*...*\u002F }\n\n\u002F\u002F Good: Always return the error interface\nfunc Good() error { \u002F*...*\u002F }\n```\n\n### Error Strings\n\nError strings should **not** be capitalized and should **not** end with\npunctuation. Exception: exported names, proper nouns, or acronyms.\n\n```go\n\u002F\u002F Bad\nerr := fmt.Errorf(\"Something bad happened.\")\n\n\u002F\u002F Good\nerr := fmt.Errorf(\"something bad happened\")\n```\n\nFor displayed messages (logs, test failures, API responses), capitalization is\nappropriate.\n\n### Return Values on Error\n\nWhen a function returns an error, callers must treat all non-error return values\nas unspecified unless explicitly documented.\n\n**Tip**: Functions taking a `context.Context` should usually return an `error`\nso callers can determine if the context was cancelled.\n\n---\n\n## Handling Errors\n\nWhen encountering an error, make a **deliberate choice** — do not discard\nwith `_`:\n\n1. **Handle immediately** — address the error and continue\n2. **Return to caller** — optionally wrapped with context\n3. **In exceptional cases** — `log.Fatal` or `panic`\n\nTo intentionally ignore: add a comment explaining why.\n\n```go\nn, _ := b.Write(p) \u002F\u002F never returns a non-nil error\n```\n\nFor related concurrent operations, use\n[`errgroup`](https:\u002F\u002Fpkg.go.dev\u002Fgolang.org\u002Fx\u002Fsync\u002Ferrgroup):\n\n```go\ng, ctx := errgroup.WithContext(ctx)\ng.Go(func() error { return task1(ctx) })\ng.Go(func() error { return task2(ctx) })\nif err := g.Wait(); err != nil { return err }\n```\n\n### Avoid In-Band Errors\n\nDon't return `-1`, `nil`, or empty string to signal errors. Use multiple\nreturns:\n\n```go\n\u002F\u002F Bad: In-band error value\nfunc Lookup(key string) int  \u002F\u002F returns -1 for missing\n\n\u002F\u002F Good: Explicit error or ok value\nfunc Lookup(key string) (string, bool)\n```\n\nThis prevents callers from writing `Parse(Lookup(key))` — it causes a\ncompile-time error since `Lookup(key)` has 2 outputs.\n\n---\n\n## Error Flow\n\nHandle errors before normal code. Early returns keep the happy path unindented:\n\n```go\n\u002F\u002F Good: Error first, normal code unindented\nif err != nil {\n    return err\n}\n\u002F\u002F normal code\n```\n\n**Handle errors once** — either log or return, never both:\n\n```\nError encountered?\n├─ Caller can act on it? → Return (with context via %w)\n├─ Top of call chain? → Log and handle\n└─ Neither? → Log at appropriate level, continue\n```\n\n---\n\n## Error Types\n\n> **Advisory**: Recommended best practice.\n\n| Caller needs to match? | Message type | Use |\n|------------------------|--------------|-----|\n| No | static | `errors.New(\"message\")` |\n| No | dynamic | `fmt.Errorf(\"msg: %v\", val)` |\n| Yes | static | `var ErrFoo = errors.New(\"...\")` |\n| Yes | dynamic | custom `error` type |\n\n**Default**: Wrap with `fmt.Errorf(\"...: %w\", err)`. Escalate to sentinels for\n`errors.Is()`, to custom types for `errors.As()`.\n\n---\n\n## Error Wrapping\n\n> **Advisory**: Recommended best practice.\n\n- **Use `%v`**: At system boundaries, for logging, to hide internal details\n- **Use `%w`**: To preserve error chain for `errors.Is`\u002F`errors.As`\n\n**Key rules**: Place `%w` at the end. Add context callers don't have. If\nannotation adds nothing, return `err` directly.\n\n> **Validation**: After implementing error handling, run `bash scripts\u002Fcheck-errors.sh` to detect common anti-patterns. Then run `go vet .\u002F...` to catch additional issues.\n\n---\n\n## Related Skills\n\n- **Error naming**: See [go-naming](..\u002Fgo-naming\u002FSKILL.md) when naming sentinel errors (`ErrFoo`) or custom error types\n- **Testing errors**: See [go-testing](..\u002Fgo-testing\u002FSKILL.md) when testing error semantics with `errors.Is`\u002F`errors.As` or writing error-checking helpers\n- **Panic handling**: See [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) when deciding between panic and error returns, or writing recover guards\n- **Guard clauses**: See [go-control-flow](..\u002Fgo-control-flow\u002FSKILL.md) when structuring early-return error flow or reducing nesting\n- **Logging decisions**: See [go-logging](..\u002Fgo-logging\u002FSKILL.md) when choosing log levels, configuring structured logging, or deciding what context to include in log messages\n","# Go Error Handling\n\n> Compatibility: `errors.Is`, `errors.As`, and `%w` wrapping require Go 1.13+; structured logging examples may use `log\u002Fslog` from Go 1.21+.\n\n## Resource Routing\n\n- `scripts\u002Fcheck-errors.sh` - Run when checking string-based error matching, bare error propagation, and log-and-return patterns.\n- `scripts\u002Fcheck-errors-ast.go` - Implementation helper invoked by `check-errors.sh`; patch this when changing error-flow analysis behavior.\n- `references\u002FERROR-FLOW.md` - Read when deciding where to handle, wrap, log, or return errors.\n- `references\u002FERROR-TYPES.md` - Read when choosing sentinel errors, typed errors, or opaque errors.\n- `references\u002FWRAPPING.md` - Read when choosing `%w` versus `%v` or crossing package boundaries.\n\nIn Go, [errors are values](https:\u002F\u002Fgo.dev\u002Fblog\u002Ferrors-are-values) — they are\ncreated by code and consumed by code.\n\n## Choosing an Error Strategy\n\n1. System boundary (RPC, IPC, storage)? → Wrap with `%v` to avoid leaking internals\n2. Caller needs to match specific conditions? → Sentinel or typed error, wrap with `%w`\n3. Caller just needs debugging context? → `fmt.Errorf(\"...: %w\", err)`\n4. Leaf function, no wrapping needed? → Return the error directly\n\n**Default**: wrap with `%w` and place it at the end of the format string.\n\n---\n\n## Core Rules\n\n### Never Return Concrete Error Types\n\n**Never return concrete error types from exported functions** — a concrete `nil`\npointer can become a non-nil interface:\n\n```go\n\u002F\u002F Bad: Concrete type can cause subtle bugs\nfunc Bad() *os.PathError { \u002F*...*\u002F }\n\n\u002F\u002F Good: Always return the error interface\nfunc Good() error { \u002F*...*\u002F }\n```\n\n### Error Strings\n\nError strings should **not** be capitalized and should **not** end with\npunctuation. Exception: exported names, proper nouns, or acronyms.\n\n```go\n\u002F\u002F Bad\nerr := fmt.Errorf(\"Something bad happened.\")\n\n\u002F\u002F Good\nerr := fmt.Errorf(\"something bad happened\")\n```\n\nFor displayed messages (logs, test failures, API responses), capitalization is\nappropriate.\n\n### Return Values on Error\n\nWhen a function returns an error, callers must treat all non-error return values\nas unspecified unless explicitly documented.\n\n**Tip**: Functions taking a `context.Context` should usually return an `error`\nso callers can determine if the context was cancelled.\n\n---\n\n## Handling Errors\n\nWhen encountering an error, make a **deliberate choice** — do not discard\nwith `_`:\n\n1. **Handle immediately** — address the error and continue\n2. **Return to caller** — optionally wrapped with context\n3. **In exceptional cases** — `log.Fatal` or `panic`\n\nTo intentionally ignore: add a comment explaining why.\n\n```go\nn, _ := b.Write(p) \u002F\u002F never returns a non-nil error\n```\n\nFor related concurrent operations, use\n[`errgroup`](https:\u002F\u002Fpkg.go.dev\u002Fgolang.org\u002Fx\u002Fsync\u002Ferrgroup):\n\n```go\ng, ctx := errgroup.WithContext(ctx)\ng.Go(func() error { return task1(ctx) })\ng.Go(func() error { return task2(ctx) })\nif err := g.Wait(); err != nil { return err }\n```\n\n### Avoid In-Band Errors\n\nDon't return `-1`, `nil`, or empty string to signal errors. Use multiple\nreturns:\n\n```go\n\u002F\u002F Bad: In-band error value\nfunc Lookup(key string) int  \u002F\u002F returns -1 for missing\n\n\u002F\u002F Good: Explicit error or ok value\nfunc Lookup(key string) (string, bool)\n```\n\nThis prevents callers from writing `Parse(Lookup(key))` — it causes a\ncompile-time error since `Lookup(key)` has 2 outputs.\n\n---\n\n## Error Flow\n\nHandle errors before normal code. Early returns keep the happy path unindented:\n\n```go\n\u002F\u002F Good: Error first, normal code unindented\nif err != nil {\n    return err\n}\n\u002F\u002F normal code\n```\n\n**Handle errors once** — either log or return, never both:\n\n```\nError encountered?\n├─ Caller can act on it? → Return (with context via %w)\n├─ Top of call chain? → Log and handle\n└─ Neither? → Log at appropriate level, continue\n```\n\n---\n\n## Error Types\n\n> **Advisory**: Recommended best practice.\n\n| Caller needs to match? | Message type | Use |\n|------------------------|--------------|-----|\n| No | static | `errors.New(\"message\")` |\n| No | dynamic | `fmt.Errorf(\"msg: %v\", val)` |\n| Yes | static | `var ErrFoo = errors.New(\"...\")` |\n| Yes | dynamic | custom `error` type |\n\n**Default**: Wrap with `fmt.Errorf(\"...: %w\", err)`. Escalate to sentinels for\n`errors.Is()`, to custom types for `errors.As()`.\n\n---\n\n## Error Wrapping\n\n> **Advisory**: Recommended best practice.\n\n- **Use `%v`**: At system boundaries, for logging, to hide internal details\n- **Use `%w`**: To preserve error chain for `errors.Is`\u002F`errors.As`\n\n**Key rules**: Place `%w` at the end. Add context callers don't have. If\nannotation adds nothing, return `err` directly.\n\n> **Validation**: After implementing error handling, run `bash scripts\u002Fcheck-errors.sh` to detect common anti-patterns. Then run `go vet .\u002F...` to catch additional issues.\n\n---\n\n## Related Skills\n\n- **Error naming**: See [go-naming](..\u002Fgo-naming\u002FSKILL.md) when naming sentinel errors (`ErrFoo`) or custom error types\n- **Testing errors**: See [go-testing](..\u002Fgo-testing\u002FSKILL.md) when testing error semantics with `errors.Is`\u002F`errors.As` or writing error-checking helpers\n- **Panic handling**: See [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) when deciding between panic and error returns, or writing recover guards\n- **Guard clauses**: See [go-control-flow](..\u002Fgo-control-flow\u002FSKILL.md) when structuring early-return error flow or reducing nesting\n- **Logging decisions**: See [go-logging](..\u002Fgo-logging\u002FSKILL.md) when choosing log levels, configuring structured logging, or deciding what context to include in log messages\n",{"name":5,"description":7,"allowed-tools":24},"Bash(bash:*)","main","19f4d52a98d557f3a645a2cfbbeb5bd54f28831d",".github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling","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":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add kongnakornna\u002Fgolangapi --skill go-error-handling",{"tool":39,"command":40},"bunx","bunx skills add kongnakornna\u002Fgolangapi --skill go-error-handling",{"tool":42,"command":43},"pnpm","pnpm dlx skills add kongnakornna\u002Fgolangapi --skill go-error-handling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling\u002FSKILL.md",true,[47,53,57,61,67],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"references\u002FERROR-FLOW.md","REFERENCE","参考文档",4119,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling\u002Freferences\u002FERROR-FLOW.md",{"path":54,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":55,"sourceHtmlUrl":56},"references\u002FERROR-TYPES.md",3567,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling\u002Freferences\u002FERROR-TYPES.md",{"path":58,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":59,"sourceHtmlUrl":60},"references\u002FWRAPPING.md",5042,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling\u002Freferences\u002FWRAPPING.md",{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"scripts\u002Fcheck-errors-ast.go","SCRIPT","脚本",9726,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling\u002Fscripts\u002Fcheck-errors-ast.go",{"path":68,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":69,"sourceHtmlUrl":70},"scripts\u002Fcheck-errors.sh",1312,"https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Fgolang-skills\u002Fskills\u002Fgo-error-handling\u002Fscripts\u002Fcheck-errors.sh",[72,79,86,93,100,107],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M7A0M9RJJ3383VEFYKABWV15","tb-writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002Fkongnakornna\u002Fgolangapi\u002Fblob\u002Fmain\u002F.github\u002Fskills\u002Ftb-writing-plans\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"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":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"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":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"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":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"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":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"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",[],[]]