[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F3J2SWEP111FB35R3XWW2A":3,"skill-same:01M6F3J2SWEP111FB35R3XWW2A":64},{"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":33,"linkOnly":34,"markdownContent":35,"markdownBody":36,"frontMatter":37,"refName":41,"commitSha":42,"skillDirectory":43,"forksCount":44,"repositoryHtmlUrl":45,"repositoryHomepageUrl":46,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6F3J2SWEP111FB35R3XWW2A","go-interfaces",null,"Use when defining or implementing Go interfaces, designing abstractions, creating mockable boundaries for testing, or composing types through embedding. Also use when deciding whether to accept an interface or return a concrete type, or using type assertions or type switches, even if the user doesn't explicitly mention interfaces. Does not cover generics-based polymorphism (see go-generics).","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-interfaces\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32],"go","go interfaces","testing","google","Bash","Effective Go","user","guide","use","type","style","embedding","types","interface","2026-11-10 10:12:30",false,"---\nname: go-interfaces\ndescription: Use when defining or implementing Go interfaces, designing abstractions, creating mockable boundaries for testing, or composing types through embedding. Also use when deciding whether to accept an interface or return a concrete type, or using type assertions or type switches, even if the user doesn't explicitly mention interfaces. Does not cover generics-based polymorphism (see go-generics).\nlicense: Apache-2.0\nmetadata:\n  sources: \"Effective Go, Google Style Guide, Uber Style Guide\"\nallowed-tools: Bash(bash:*)\n---\n\n# Go Interfaces and Composition\n\n## Available Scripts\n\n- **`scripts\u002Fcheck-interface-compliance.sh`** — Finds exported interfaces missing compile-time compliance checks (`var _ I = (*T)(nil)`). Run `bash scripts\u002Fcheck-interface-compliance.sh --help` for options.\n\n---\n\n## Accept Interfaces, Return Concrete Types\n\nInterfaces belong in the package that **consumes** values, not the package that\n**implements** them. Return concrete (usually pointer or struct) types from\nconstructors so new methods can be added without refactoring.\n\n```go\n\u002F\u002F Good: consumer defines the interface it needs\npackage consumer\n\ntype Thinger interface { Thing() bool }\n\nfunc Foo(t Thinger) string { ... }\n```\n\n```go\n\u002F\u002F Good: producer returns concrete type\npackage producer\n\ntype Thinger struct{ ... }\nfunc (t Thinger) Thing() bool { ... }\nfunc NewThinger() Thinger { return Thinger{ ... } }\n```\n\n```go\n\u002F\u002F Bad: producer defines and returns its own interface\npackage producer\n\ntype Thinger interface { Thing() bool }\ntype defaultThinger struct{ ... }\nfunc NewThinger() Thinger { return defaultThinger{ ... } }\n```\n\n**Do not define interfaces before they are used.** Without a realistic example\nof usage, it is too difficult to see whether an interface is even necessary.\n\n---\n\n## Generality: Hide Implementation, Expose Interface\n\nIf a type exists only to implement an interface with no exported methods beyond\nthat interface, return the interface from constructors to hide the implementation:\n\n```go\nfunc NewHash() hash.Hash32 {\n    return &myHash{}  \u002F\u002F unexported type\n}\n```\n\nBenefits: implementation can change without affecting callers, substituting\nalgorithms requires only changing the constructor call.\n\n---\n\n## Type Assertions: Comma-Ok Idiom\n\nWithout checking, a failed assertion causes a runtime panic. Always use the\ncomma-ok idiom to test safely:\n\n```go\nstr, ok := value.(string)\nif ok {\n    fmt.Printf(\"string value is: %q\\n\", str)\n}\n```\n\nTo check if a value implements an interface:\n\n```go\nif _, ok := val.(json.Marshaler); ok {\n    fmt.Printf(\"value %v implements json.Marshaler\\n\", val)\n}\n```\n\n---\n\n## Type Switch\n\nIt's idiomatic to reuse the variable name (`t := t.(type)`) — the variable has\nthe correct type in each case branch. When a case lists multiple types\n(`case int, int64:`), the variable has the interface type.\n\n---\n\n## Embedding\n\nAvoid embedding types in public structs — the inner type's full method set\nbecomes part of your public API. Use unexported fields instead.\n\n> Read [references\u002FEMBEDDING.md](references\u002FEMBEDDING.md) when using struct embedding for composition, overriding embedded methods, resolving name conflicts, applying the HandlerFunc adapter pattern, or deciding whether to embed in public API types.\n\n---\n\n## Interface Satisfaction Checks\n\nUse a blank identifier assignment to verify a type implements an interface at\ncompile time:\n\n```go\nvar _ json.Marshaler = (*RawMessage)(nil)\n```\n\nThis causes a compile error if `*RawMessage` doesn't implement `json.Marshaler`.\n\nUse this pattern when:\n- There are no static conversions that would verify the interface automatically\n- The type must satisfy an interface for correct behavior (e.g., custom JSON\n  marshaling)\n- Interface changes should break compilation, not silently degrade\n\n**Don't** add these checks for every interface — only when no other static\nconversion would catch the error.\n\n> **Validation**: After defining interfaces or implementations, run `bash scripts\u002Fcheck-interface-compliance.sh` to verify all concrete types have compile-time `var _ I = (*T)(nil)` checks.\n\n---\n\n## Receiver Type\n\nIf in doubt, use a pointer receiver. Don't mix receiver types on a single\ntype — if any method needs a pointer, use pointers for all methods. Use value\nreceivers only for small, immutable types (`Point`, `time.Time`) or basic types.\n\n> Read [references\u002FRECEIVER-TYPE.md](references\u002FRECEIVER-TYPE.md) when deciding between pointer and value receivers for a new type, especially for types with sync primitives or large structs.\n\n---\n\n## Quick Reference\n\n| Concept | Pattern | Notes |\n|---------|---------|-------|\n| Consumer owns interface | Define interfaces where used | Not in the implementing package |\n| Safe type assertion | `v, ok := x.(Type)` | Returns zero value + false |\n| Type switch | `switch v := x.(type)` | Variable has correct type per case |\n| Interface embedding | `type RW interface { Reader; Writer }` | Union of methods |\n| Struct embedding | `type S struct { *T }` | Promotes T's methods |\n| Interface check | `var _ I = (*T)(nil)` | Compile-time verification |\n| Generality | Return interface from constructor | Hide implementation |\n\n---\n\n## Related Skills\n\n- **Interface naming**: See [go-naming](..\u002Fgo-naming\u002FSKILL.md) when naming interfaces (the `-er` suffix convention) or choosing receiver names\n- **Error types**: See [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) when implementing the `error` interface, custom error types, or `errors.As` matching\n- **Generics vs interfaces**: See [go-generics](..\u002Fgo-generics\u002FSKILL.md) when deciding whether generics are needed or an interface already suffices\n- **Functional options**: See [go-functional-options](..\u002Fgo-functional-options\u002FSKILL.md) when using an interface-based Option pattern for flexible constructors\n- **Compile-time checks**: See [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) when adding `var _ I = (*T)(nil)` satisfaction checks at API boundaries\n\n","# Go Interfaces and Composition\n\n## Available Scripts\n\n- **`scripts\u002Fcheck-interface-compliance.sh`** — Finds exported interfaces missing compile-time compliance checks (`var _ I = (*T)(nil)`). Run `bash scripts\u002Fcheck-interface-compliance.sh --help` for options.\n\n---\n\n## Accept Interfaces, Return Concrete Types\n\nInterfaces belong in the package that **consumes** values, not the package that\n**implements** them. Return concrete (usually pointer or struct) types from\nconstructors so new methods can be added without refactoring.\n\n```go\n\u002F\u002F Good: consumer defines the interface it needs\npackage consumer\n\ntype Thinger interface { Thing() bool }\n\nfunc Foo(t Thinger) string { ... }\n```\n\n```go\n\u002F\u002F Good: producer returns concrete type\npackage producer\n\ntype Thinger struct{ ... }\nfunc (t Thinger) Thing() bool { ... }\nfunc NewThinger() Thinger { return Thinger{ ... } }\n```\n\n```go\n\u002F\u002F Bad: producer defines and returns its own interface\npackage producer\n\ntype Thinger interface { Thing() bool }\ntype defaultThinger struct{ ... }\nfunc NewThinger() Thinger { return defaultThinger{ ... } }\n```\n\n**Do not define interfaces before they are used.** Without a realistic example\nof usage, it is too difficult to see whether an interface is even necessary.\n\n---\n\n## Generality: Hide Implementation, Expose Interface\n\nIf a type exists only to implement an interface with no exported methods beyond\nthat interface, return the interface from constructors to hide the implementation:\n\n```go\nfunc NewHash() hash.Hash32 {\n    return &myHash{}  \u002F\u002F unexported type\n}\n```\n\nBenefits: implementation can change without affecting callers, substituting\nalgorithms requires only changing the constructor call.\n\n---\n\n## Type Assertions: Comma-Ok Idiom\n\nWithout checking, a failed assertion causes a runtime panic. Always use the\ncomma-ok idiom to test safely:\n\n```go\nstr, ok := value.(string)\nif ok {\n    fmt.Printf(\"string value is: %q\\n\", str)\n}\n```\n\nTo check if a value implements an interface:\n\n```go\nif _, ok := val.(json.Marshaler); ok {\n    fmt.Printf(\"value %v implements json.Marshaler\\n\", val)\n}\n```\n\n---\n\n## Type Switch\n\nIt's idiomatic to reuse the variable name (`t := t.(type)`) — the variable has\nthe correct type in each case branch. When a case lists multiple types\n(`case int, int64:`), the variable has the interface type.\n\n---\n\n## Embedding\n\nAvoid embedding types in public structs — the inner type's full method set\nbecomes part of your public API. Use unexported fields instead.\n\n> Read [references\u002FEMBEDDING.md](references\u002FEMBEDDING.md) when using struct embedding for composition, overriding embedded methods, resolving name conflicts, applying the HandlerFunc adapter pattern, or deciding whether to embed in public API types.\n\n---\n\n## Interface Satisfaction Checks\n\nUse a blank identifier assignment to verify a type implements an interface at\ncompile time:\n\n```go\nvar _ json.Marshaler = (*RawMessage)(nil)\n```\n\nThis causes a compile error if `*RawMessage` doesn't implement `json.Marshaler`.\n\nUse this pattern when:\n- There are no static conversions that would verify the interface automatically\n- The type must satisfy an interface for correct behavior (e.g., custom JSON\n  marshaling)\n- Interface changes should break compilation, not silently degrade\n\n**Don't** add these checks for every interface — only when no other static\nconversion would catch the error.\n\n> **Validation**: After defining interfaces or implementations, run `bash scripts\u002Fcheck-interface-compliance.sh` to verify all concrete types have compile-time `var _ I = (*T)(nil)` checks.\n\n---\n\n## Receiver Type\n\nIf in doubt, use a pointer receiver. Don't mix receiver types on a single\ntype — if any method needs a pointer, use pointers for all methods. Use value\nreceivers only for small, immutable types (`Point`, `time.Time`) or basic types.\n\n> Read [references\u002FRECEIVER-TYPE.md](references\u002FRECEIVER-TYPE.md) when deciding between pointer and value receivers for a new type, especially for types with sync primitives or large structs.\n\n---\n\n## Quick Reference\n\n| Concept | Pattern | Notes |\n|---------|---------|-------|\n| Consumer owns interface | Define interfaces where used | Not in the implementing package |\n| Safe type assertion | `v, ok := x.(Type)` | Returns zero value + false |\n| Type switch | `switch v := x.(type)` | Variable has correct type per case |\n| Interface embedding | `type RW interface { Reader; Writer }` | Union of methods |\n| Struct embedding | `type S struct { *T }` | Promotes T's methods |\n| Interface check | `var _ I = (*T)(nil)` | Compile-time verification |\n| Generality | Return interface from constructor | Hide implementation |\n\n---\n\n## Related Skills\n\n- **Interface naming**: See [go-naming](..\u002Fgo-naming\u002FSKILL.md) when naming interfaces (the `-er` suffix convention) or choosing receiver names\n- **Error types**: See [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) when implementing the `error` interface, custom error types, or `errors.As` matching\n- **Generics vs interfaces**: See [go-generics](..\u002Fgo-generics\u002FSKILL.md) when deciding whether generics are needed or an interface already suffices\n- **Functional options**: See [go-functional-options](..\u002Fgo-functional-options\u002FSKILL.md) when using an interface-based Option pattern for flexible constructors\n- **Compile-time checks**: See [go-defensive](..\u002Fgo-defensive\u002FSKILL.md) when adding `var _ I = (*T)(nil)` satisfaction checks at API boundaries\n\n",{"name":5,"license":15,"metadata":38,"description":7,"allowed-tools":40},{"sources":39},"Effective Go, Google Style Guide, Uber Style Guide","Bash(bash:*)","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fcxuu\u002Fgolang-skills\u002Fgo-interfaces",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":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill go-interfaces",{"tool":56,"command":57},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill go-interfaces",{"tool":59,"command":60},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill go-interfaces","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fcxuu\u002Fgolang-skills\u002Fgo-interfaces\u002FSKILL.md",true,[],[65,75,84,93,99,105],{"skillNo":66,"name":67,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":33},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[72,73,74],"model","model hierarchy","model hierarchy skill",{"skillNo":76,"name":77,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":33},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[81,82,83],"MCP","zoom","zoom mcp",{"skillNo":85,"name":86,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":33},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[90,91,92,82],"sdk","zoom apps sdk","apps",{"skillNo":94,"name":95,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":33},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[95],{"skillNo":100,"name":101,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":33},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[101],{"skillNo":106,"name":107,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":68,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":33},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[107]]