[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F3HK5D414ZPTT1B6MMDE0C":3,"skill-same:01M6F3HK5D414ZPTT1B6MMDE0C":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":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":53,"ownerHtmlUrl":54,"ownerBlogUrl":6,"ownerDescription":55,"updatedAt":56,"install":57,"resources":70},"01M6F3HK5D414ZPTT1B6MMDE0C","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).","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fcxuu\u002Fgolang-skills\u002Fgo-error-handling\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"go","go error handling","error","error handling","log","writing","structured logging","types","code","defensive","style","as","across","use","strategy","ask","writing go","Bash","examples","package","2026-11-10 10:12:30",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).\nlicense: Apache-2.0\ncompatibility: Requires Go 1.13+ for errors.Is\u002Ferrors.As and fmt.Errorf %w wrapping. Structured logging examples use slog (Go 1.21+).\nmetadata:\n  sources: \"Google Style Guide, Uber Style Guide\"\nallowed-tools: Bash(bash:*)\n---\n\n# Go Error Handling\n\n## Available Scripts\n\n- **`scripts\u002Fcheck-errors.sh`** — Detects error handling anti-patterns: string comparison on `err.Error()`, bare `return err` without context, and log-and-return violations. Run `bash scripts\u002Fcheck-errors.sh --help` for options.\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> Read [references\u002FERROR-FLOW.md](references\u002FERROR-FLOW.md) when structuring complex error flows, deciding between logging vs returning, implementing the handle-once pattern, or choosing structured logging levels.\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> Read [references\u002FERROR-TYPES.md](references\u002FERROR-TYPES.md) when defining sentinel errors, creating custom error types, or choosing error strategies for a package API.\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> Read [references\u002FWRAPPING.md](references\u002FWRAPPING.md) when deciding between %v and %w, wrapping errors across package boundaries, or adding contextual information.\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\n\n","# Go Error Handling\n\n## Available Scripts\n\n- **`scripts\u002Fcheck-errors.sh`** — Detects error handling anti-patterns: string comparison on `err.Error()`, bare `return err` without context, and log-and-return violations. Run `bash scripts\u002Fcheck-errors.sh --help` for options.\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> Read [references\u002FERROR-FLOW.md](references\u002FERROR-FLOW.md) when structuring complex error flows, deciding between logging vs returning, implementing the handle-once pattern, or choosing structured logging levels.\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> Read [references\u002FERROR-TYPES.md](references\u002FERROR-TYPES.md) when defining sentinel errors, creating custom error types, or choosing error strategies for a package API.\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> Read [references\u002FWRAPPING.md](references\u002FWRAPPING.md) when deciding between %v and %w, wrapping errors across package boundaries, or adding contextual information.\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\n\n",{"name":5,"license":15,"metadata":44,"description":7,"allowed-tools":46,"compatibility":47},{"sources":45},"Google Style Guide, Uber Style Guide","Bash(bash:*)","Requires Go 1.13+ for errors.Is\u002Ferrors.As and fmt.Errorf %w wrapping. Structured logging examples use slog (Go 1.21+).","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fcxuu\u002Fgolang-skills\u002Fgo-error-handling",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill go-error-handling",{"tool":63,"command":64},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill go-error-handling",{"tool":66,"command":67},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill go-error-handling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fcxuu\u002Fgolang-skills\u002Fgo-error-handling\u002FSKILL.md",true,[],[72,82,91,100,106,112],{"skillNo":73,"name":74,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":39},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[79,80,81],"model","model hierarchy","model hierarchy skill",{"skillNo":83,"name":84,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[88,89,90],"MCP","zoom","zoom mcp",{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[97,98,99,89],"sdk","zoom apps sdk","apps",{"skillNo":101,"name":102,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[102],{"skillNo":107,"name":108,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[108],{"skillNo":113,"name":114,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[114]]