[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M76HAPGC09RM2RJ7QDXE703N":3,"skill-same:01M76HAPGC09RM2RJ7QDXE703N":68},{"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":39,"commitSha":40,"skillDirectory":41,"forksCount":42,"repositoryHtmlUrl":43,"repositoryHomepageUrl":44,"ownerHtmlUrl":45,"ownerBlogUrl":46,"ownerDescription":47,"updatedAt":48,"install":49,"resources":61},"01M76HAPGC09RM2RJ7QDXE703N","golang-structs-interfaces",null,"Golang struct and interface design patterns — composition, embedding, type assertions, type switches, interface segregation, dependency injection via interfaces, struct field tags, and pointer vs value receivers. Use this skill when designing Go types, defining or implementing interfaces, embedding structs or interfaces, writing type assertions or type switches, adding struct field tags for JSON\u002FYAML\u002FDB serialization, or choosing between pointer and value receivers. Also use when the user asks about \"accept interfaces, return structs\", compile-time interface checks, or composing small interfaces into larger ones.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fgolang-structs-interfaces\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: golang-structs-interfaces\ndescription: 'Golang struct and interface design patterns — composition, embedding, type assertions, type switches, interface segregation, dependency injection via interfaces, struct field tags, and pointer vs value receivers. Use this skill when designing Go types, defining or implementing interfaces, embedding structs or interfaces, writing type assertions or type switches, adding struct field tags for JSON\u002FYAML\u002FDB serialization, or choosing between pointer and value receivers. Also use when the user asks about \"accept interfaces, return structs\", compile-time interface checks, or composing small interfaces into larger ones.'\nuser-invocable: true\nlicense: MIT\ncompatibility: Designed for Claude Code, Codex or similar harness, and for projects using Golang.\nmetadata:\n  author: samber\n  version: \"1.2.1\"\n  openclaw:\n    emoji: \"🧩\"\n    homepage: https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang\n    requires:\n      bins:\n        - go\n    install: []\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestion\npaths:\n  - \"**\u002F*.go\"\n---\n\n**Persona:** You are a Go type system designer. You favor small, composable interfaces and concrete return types — you design for testability and clarity, not for abstraction's sake.\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-structs-interfaces` skill takes precedence.\n\n# Go Structs & Interfaces\n\n## Interface Design Principles\n\n### Keep Interfaces Small\n\n> \"The bigger the interface, the weaker the abstraction.\" — Go Proverbs\n\nInterfaces SHOULD have 1-3 methods. Small interfaces are easier to implement, mock, and compose. If you need a larger contract, compose it from small interfaces:\n\n→ See `samber\u002Fcc-skills-golang@golang-naming` skill for interface naming conventions (method + \"-er\" suffix, canonical names)\n\n```go\ntype Reader interface {\n    Read(p []byte) (n int, err error)\n}\n\ntype Writer interface {\n    Write(p []byte) (n int, err error)\n}\n\n\u002F\u002F Composed from small interfaces\ntype ReadWriter interface {\n    Reader\n    Writer\n}\n```\n\nCompose larger interfaces from smaller ones:\n\n```go\ntype ReadWriteCloser interface {\n    io.Reader\n    io.Writer\n    io.Closer\n}\n```\n\n### Define Interfaces Where They're Consumed\n\nInterfaces Belong to Consumers.\n\nInterfaces MUST be defined where consumed, not where implemented. This keeps the consumer in control of the contract and avoids importing a package just for its interface.\n\n```go\n\u002F\u002F package notification — defines only what it needs\ntype Sender interface {\n    Send(to, body string) error\n}\n\ntype Service struct {\n    sender Sender\n}\n```\n\nThe `email` package exports a concrete `Client` struct — it doesn't need to know about `Sender`.\n\n### Accept Interfaces, Return Structs\n\nFunctions SHOULD accept interface parameters for flexibility and return concrete types for clarity. Callers get full access to the returned type's fields and methods; consumers upstream can still assign the result to an interface variable if needed.\n\n```go\n\u002F\u002F Good — accepts interface, returns concrete\nfunc NewService(store UserStore) *Service { ... }\n\n\u002F\u002F Bad — an interface return hides every other method of the concrete type from callers\nfunc NewService(store UserStore) ServiceInterface { ... }\n```\n\n### Don't Create Interfaces Prematurely\n\n> \"Don't design with interfaces, discover them.\"\n\nAn interface written before a second implementation exists is a guess about which methods will vary — and the guess is usually wrong, so the abstraction has to be reshaped anyway. Meanwhile it costs a layer of indirection that hides the concrete type from readers and tooling. Start with concrete types; extract an interface once a second consumer, a second implementation, or a test mock demands it.\n\n```go\n\u002F\u002F Bad — premature interface with a single implementation\ntype UserRepository interface {\n    FindByID(ctx context.Context, id string) (*User, error)\n}\ntype userRepository struct { db *sql.DB }\n\n\u002F\u002F Good — start concrete, extract an interface later when needed\ntype UserRepository struct { db *sql.DB }\n```\n\n## Make the Zero Value Useful\n\nDesign structs so they work without explicit initialization. A well-designed zero value reduces constructor boilerplate and prevents nil-related bugs:\n\n```go\n\u002F\u002F Good — zero value is ready to use\nvar buf bytes.Buffer\nbuf.WriteString(\"hello\")\n\nvar mu sync.Mutex\nmu.Lock()\n\n\u002F\u002F Bad — zero value is broken, requires constructor\ntype Registry struct {\n    items map[string]Item \u002F\u002F nil map, panics on write\n}\n\n\u002F\u002F Good — lazy initialization guards the zero value\nfunc (r *Registry) Register(name string, item Item) {\n    if r.items == nil {\n        r.items = make(map[string]Item)\n    }\n    r.items[name] = item\n}\n```\n\n## Avoid `any` \u002F `interface{}` When a Specific Type Will Do\n\nSince Go 1.18+, MUST prefer generics over `any` for type-safe operations. Use `any` only at true boundaries where the type is genuinely unknown (e.g., JSON decoding, reflection):\n\n```go\n\u002F\u002F Bad — loses type safety\nfunc Contains(slice []any, target any) bool { ... }\n\n\u002F\u002F Good — generic, type-safe\nfunc Contains[T comparable](slice []T, target T) bool { ... }\n```\n\n## Key Standard Library Interfaces\n\n| Interface     | Package         | Method                                |\n| ------------- | --------------- | ------------------------------------- |\n| `Reader`      | `io`            | `Read(p []byte) (n int, err error)`   |\n| `Writer`      | `io`            | `Write(p []byte) (n int, err error)`  |\n| `Closer`      | `io`            | `Close() error`                       |\n| `Stringer`    | `fmt`           | `String() string`                     |\n| `error`       | builtin         | `Error() string`                      |\n| `Handler`     | `net\u002Fhttp`      | `ServeHTTP(ResponseWriter, *Request)` |\n| `Marshaler`   | `encoding\u002Fjson` | `MarshalJSON() ([]byte, error)`       |\n| `Unmarshaler` | `encoding\u002Fjson` | `UnmarshalJSON([]byte) error`         |\n\nCanonical method signatures MUST be honored — if your type has a `String()` method, it must match `fmt.Stringer`. Don't invent `ToString()` or `ReadData()`.\n\n## Compile-Time Interface Check\n\nVerify a type implements an interface at compile time with a blank identifier assignment. Place it near the type definition:\n\n```go\nvar _ io.ReadWriter = (*MyBuffer)(nil)\n```\n\nThis costs nothing at runtime. If `MyBuffer` ever stops satisfying `io.ReadWriter`, the build fails immediately.\n\n## Type Assertions & Type Switches\n\nType assertions MUST use the comma-ok form (`s, ok := val.(string)`) — the single-value form panics on a type mismatch instead of branching. Use a type switch to dispatch on the dynamic type, and an assertion to a small optional interface (`if f, ok := w.(Flusher); ok`) to exploit richer implementations without widening the declared parameter type.\n\n→ See [Type Assertions & Type Switches](references\u002Ftype-assertions.md) for type switch ordering, nil cases, and the optional-behavior pattern.\n\n## Struct & Interface Embedding\n\n### Struct Embedding\n\nEmbedding promotes the inner type's methods and fields to the outer type — composition, not inheritance:\n\n```go\ntype Logger struct {\n    *slog.Logger\n}\n\ntype Server struct {\n    Logger\n    addr string\n}\n\n\u002F\u002F s.Info(...) works — promoted from slog.Logger through Logger\ns := Server{Logger: Logger{slog.Default()}, addr: \":8080\"}\ns.Info(\"starting\", \"addr\", s.addr)\n```\n\nThe receiver of promoted methods is the _inner_ type, not the outer. The outer type can override by defining its own method with the same name.\n\n### When to Embed vs Named Field\n\n| Use | When |\n| --- | --- |\n| **Embed** | You want to promote the full API of the inner type — the outer type \"is a\" enhanced version |\n| **Named field** | You only need the inner type internally — the outer type \"has a\" dependency |\n\n```go\n\u002F\u002F Embed — Server exposes all http.Handler methods\ntype Server struct {\n    http.Handler\n}\n\n\u002F\u002F Named field — Server uses the store but doesn't expose its methods\ntype Server struct {\n    store *DataStore\n}\n```\n\n## Dependency Injection via Interfaces\n\nAccept dependencies as interfaces in constructors. This decouples components and makes testing straightforward:\n\n```go\ntype UserStore interface {\n    FindByID(ctx context.Context, id string) (*User, error)\n}\n\ntype UserService struct {\n    store UserStore\n}\n\nfunc NewUserService(store UserStore) *UserService {\n    return &UserService{store: store}\n}\n```\n\nIn tests, pass a mock or stub that satisfies `UserStore` — no real database needed.\n\n## Struct Field Tags\n\nExported fields in serialized structs MUST have field tags — without one, the encoder falls back to the Go field name, so renaming a field silently changes the wire format:\n\n```go\ntype Order struct {\n    ID        string    `json:\"id\"         db:\"id\"`\n    Total     float64   `json:\"total\"      db:\"total\"`\n    CreatedAt time.Time `json:\"created_at\" db:\"created_at\"`\n    Internal  string    `json:\"-\"          db:\"-\"`\n}\n```\n\n→ See [Struct Fields: Tags and Copy Safety](references\u002Fstruct-fields.md) for the full tag directive table, the `omitempty` vs `omitzero` trap, and `go vet` diagnostics.\n\n## Pointer vs Value Receivers\n\n| Use pointer `(s *Server)` | Use value `(s Server)` |\n| --- | --- |\n| Method modifies the receiver | Receiver is small and immutable |\n| Receiver contains `sync.Mutex` or similar | Receiver is a basic type (int, string) |\n| Receiver is a large struct | Method is a read-only accessor |\n| Consistency: if any method uses a pointer, all should | Map and function values (already reference types) |\n\nReceiver type MUST be consistent across all methods of a type — if one method uses a pointer receiver, all methods should.\n\n## Preventing Struct Copies with `noCopy`\n\nA struct holding a mutex, a channel, or internal pointers breaks when copied: the copy duplicates the lock state, so two goroutines guard two different mutexes and the invariant disappears silently. Embed a `noCopy` sentinel so `go vet` reports every value copy, and pass such structs by pointer.\n\n**Diagnose:** 1- `go vet .\u002F...` — `copylocks` reports value copies of lock-bearing structs\n\n→ See [Struct Fields: Tags and Copy Safety](references\u002Fstruct-fields.md) for the `noCopy` implementation and how `vet` detects it.\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-naming` skill for interface naming conventions (Reader, Closer, Stringer)\n- → See `samber\u002Fcc-skills-golang@golang-design-patterns` skill for functional options, constructors, and builder patterns\n- → See `samber\u002Fcc-skills-golang@golang-dependency-injection` skill for DI patterns using interfaces\n- → See `samber\u002Fcc-skills-golang@golang-code-style` skill for value vs pointer function parameters (distinct from receivers)\n- → See `samber\u002Fcc-skills-golang@golang-gopls` skill for safe rename and the `implementInterface` code action — renaming a method or receiver that participates in interface satisfaction updates every call site and refuses a rename that would silently break the interface, which grep\u002Fsed cannot detect\n\n## Common Mistakes\n\n| Mistake | Fix |\n| --- | --- |\n| Large interfaces (5+ methods) | Split into focused 1-3 method interfaces, compose if needed |\n| Defining interfaces in the implementor package | Define where consumed |\n| Returning interfaces from constructors | Return concrete types |\n| Bare type assertions without comma-ok | Always use `v, ok := x.(T)` |\n| Embedding when you only need a few methods | Use a named field and delegate explicitly |\n| Missing field tags on serialized structs | Tag all exported fields in marshaled types |\n| Mixing pointer and value receivers on a type | Pick one and be consistent |\n| Forgetting compile-time interface check | Add `var _ Interface = (*Type)(nil)` |\n| Using `ToString()` instead of `String()` | Honor canonical method names |\n| Premature interface with a single implementation | Start concrete, extract interface when needed |\n| Nil map\u002Fslice in zero value struct | Use lazy initialization in methods |\n| Using `any` for type-safe operations | Use generics (`[T comparable]`) instead |\n","**Persona:** You are a Go type system designer. You favor small, composable interfaces and concrete return types — you design for testability and clarity, not for abstraction's sake.\n\n> **Community default.** A company skill that explicitly supersedes `samber\u002Fcc-skills-golang@golang-structs-interfaces` skill takes precedence.\n\n# Go Structs & Interfaces\n\n## Interface Design Principles\n\n### Keep Interfaces Small\n\n> \"The bigger the interface, the weaker the abstraction.\" — Go Proverbs\n\nInterfaces SHOULD have 1-3 methods. Small interfaces are easier to implement, mock, and compose. If you need a larger contract, compose it from small interfaces:\n\n→ See `samber\u002Fcc-skills-golang@golang-naming` skill for interface naming conventions (method + \"-er\" suffix, canonical names)\n\n```go\ntype Reader interface {\n    Read(p []byte) (n int, err error)\n}\n\ntype Writer interface {\n    Write(p []byte) (n int, err error)\n}\n\n\u002F\u002F Composed from small interfaces\ntype ReadWriter interface {\n    Reader\n    Writer\n}\n```\n\nCompose larger interfaces from smaller ones:\n\n```go\ntype ReadWriteCloser interface {\n    io.Reader\n    io.Writer\n    io.Closer\n}\n```\n\n### Define Interfaces Where They're Consumed\n\nInterfaces Belong to Consumers.\n\nInterfaces MUST be defined where consumed, not where implemented. This keeps the consumer in control of the contract and avoids importing a package just for its interface.\n\n```go\n\u002F\u002F package notification — defines only what it needs\ntype Sender interface {\n    Send(to, body string) error\n}\n\ntype Service struct {\n    sender Sender\n}\n```\n\nThe `email` package exports a concrete `Client` struct — it doesn't need to know about `Sender`.\n\n### Accept Interfaces, Return Structs\n\nFunctions SHOULD accept interface parameters for flexibility and return concrete types for clarity. Callers get full access to the returned type's fields and methods; consumers upstream can still assign the result to an interface variable if needed.\n\n```go\n\u002F\u002F Good — accepts interface, returns concrete\nfunc NewService(store UserStore) *Service { ... }\n\n\u002F\u002F Bad — an interface return hides every other method of the concrete type from callers\nfunc NewService(store UserStore) ServiceInterface { ... }\n```\n\n### Don't Create Interfaces Prematurely\n\n> \"Don't design with interfaces, discover them.\"\n\nAn interface written before a second implementation exists is a guess about which methods will vary — and the guess is usually wrong, so the abstraction has to be reshaped anyway. Meanwhile it costs a layer of indirection that hides the concrete type from readers and tooling. Start with concrete types; extract an interface once a second consumer, a second implementation, or a test mock demands it.\n\n```go\n\u002F\u002F Bad — premature interface with a single implementation\ntype UserRepository interface {\n    FindByID(ctx context.Context, id string) (*User, error)\n}\ntype userRepository struct { db *sql.DB }\n\n\u002F\u002F Good — start concrete, extract an interface later when needed\ntype UserRepository struct { db *sql.DB }\n```\n\n## Make the Zero Value Useful\n\nDesign structs so they work without explicit initialization. A well-designed zero value reduces constructor boilerplate and prevents nil-related bugs:\n\n```go\n\u002F\u002F Good — zero value is ready to use\nvar buf bytes.Buffer\nbuf.WriteString(\"hello\")\n\nvar mu sync.Mutex\nmu.Lock()\n\n\u002F\u002F Bad — zero value is broken, requires constructor\ntype Registry struct {\n    items map[string]Item \u002F\u002F nil map, panics on write\n}\n\n\u002F\u002F Good — lazy initialization guards the zero value\nfunc (r *Registry) Register(name string, item Item) {\n    if r.items == nil {\n        r.items = make(map[string]Item)\n    }\n    r.items[name] = item\n}\n```\n\n## Avoid `any` \u002F `interface{}` When a Specific Type Will Do\n\nSince Go 1.18+, MUST prefer generics over `any` for type-safe operations. Use `any` only at true boundaries where the type is genuinely unknown (e.g., JSON decoding, reflection):\n\n```go\n\u002F\u002F Bad — loses type safety\nfunc Contains(slice []any, target any) bool { ... }\n\n\u002F\u002F Good — generic, type-safe\nfunc Contains[T comparable](slice []T, target T) bool { ... }\n```\n\n## Key Standard Library Interfaces\n\n| Interface     | Package         | Method                                |\n| ------------- | --------------- | ------------------------------------- |\n| `Reader`      | `io`            | `Read(p []byte) (n int, err error)`   |\n| `Writer`      | `io`            | `Write(p []byte) (n int, err error)`  |\n| `Closer`      | `io`            | `Close() error`                       |\n| `Stringer`    | `fmt`           | `String() string`                     |\n| `error`       | builtin         | `Error() string`                      |\n| `Handler`     | `net\u002Fhttp`      | `ServeHTTP(ResponseWriter, *Request)` |\n| `Marshaler`   | `encoding\u002Fjson` | `MarshalJSON() ([]byte, error)`       |\n| `Unmarshaler` | `encoding\u002Fjson` | `UnmarshalJSON([]byte) error`         |\n\nCanonical method signatures MUST be honored — if your type has a `String()` method, it must match `fmt.Stringer`. Don't invent `ToString()` or `ReadData()`.\n\n## Compile-Time Interface Check\n\nVerify a type implements an interface at compile time with a blank identifier assignment. Place it near the type definition:\n\n```go\nvar _ io.ReadWriter = (*MyBuffer)(nil)\n```\n\nThis costs nothing at runtime. If `MyBuffer` ever stops satisfying `io.ReadWriter`, the build fails immediately.\n\n## Type Assertions & Type Switches\n\nType assertions MUST use the comma-ok form (`s, ok := val.(string)`) — the single-value form panics on a type mismatch instead of branching. Use a type switch to dispatch on the dynamic type, and an assertion to a small optional interface (`if f, ok := w.(Flusher); ok`) to exploit richer implementations without widening the declared parameter type.\n\n→ See [Type Assertions & Type Switches](references\u002Ftype-assertions.md) for type switch ordering, nil cases, and the optional-behavior pattern.\n\n## Struct & Interface Embedding\n\n### Struct Embedding\n\nEmbedding promotes the inner type's methods and fields to the outer type — composition, not inheritance:\n\n```go\ntype Logger struct {\n    *slog.Logger\n}\n\ntype Server struct {\n    Logger\n    addr string\n}\n\n\u002F\u002F s.Info(...) works — promoted from slog.Logger through Logger\ns := Server{Logger: Logger{slog.Default()}, addr: \":8080\"}\ns.Info(\"starting\", \"addr\", s.addr)\n```\n\nThe receiver of promoted methods is the _inner_ type, not the outer. The outer type can override by defining its own method with the same name.\n\n### When to Embed vs Named Field\n\n| Use | When |\n| --- | --- |\n| **Embed** | You want to promote the full API of the inner type — the outer type \"is a\" enhanced version |\n| **Named field** | You only need the inner type internally — the outer type \"has a\" dependency |\n\n```go\n\u002F\u002F Embed — Server exposes all http.Handler methods\ntype Server struct {\n    http.Handler\n}\n\n\u002F\u002F Named field — Server uses the store but doesn't expose its methods\ntype Server struct {\n    store *DataStore\n}\n```\n\n## Dependency Injection via Interfaces\n\nAccept dependencies as interfaces in constructors. This decouples components and makes testing straightforward:\n\n```go\ntype UserStore interface {\n    FindByID(ctx context.Context, id string) (*User, error)\n}\n\ntype UserService struct {\n    store UserStore\n}\n\nfunc NewUserService(store UserStore) *UserService {\n    return &UserService{store: store}\n}\n```\n\nIn tests, pass a mock or stub that satisfies `UserStore` — no real database needed.\n\n## Struct Field Tags\n\nExported fields in serialized structs MUST have field tags — without one, the encoder falls back to the Go field name, so renaming a field silently changes the wire format:\n\n```go\ntype Order struct {\n    ID        string    `json:\"id\"         db:\"id\"`\n    Total     float64   `json:\"total\"      db:\"total\"`\n    CreatedAt time.Time `json:\"created_at\" db:\"created_at\"`\n    Internal  string    `json:\"-\"          db:\"-\"`\n}\n```\n\n→ See [Struct Fields: Tags and Copy Safety](references\u002Fstruct-fields.md) for the full tag directive table, the `omitempty` vs `omitzero` trap, and `go vet` diagnostics.\n\n## Pointer vs Value Receivers\n\n| Use pointer `(s *Server)` | Use value `(s Server)` |\n| --- | --- |\n| Method modifies the receiver | Receiver is small and immutable |\n| Receiver contains `sync.Mutex` or similar | Receiver is a basic type (int, string) |\n| Receiver is a large struct | Method is a read-only accessor |\n| Consistency: if any method uses a pointer, all should | Map and function values (already reference types) |\n\nReceiver type MUST be consistent across all methods of a type — if one method uses a pointer receiver, all methods should.\n\n## Preventing Struct Copies with `noCopy`\n\nA struct holding a mutex, a channel, or internal pointers breaks when copied: the copy duplicates the lock state, so two goroutines guard two different mutexes and the invariant disappears silently. Embed a `noCopy` sentinel so `go vet` reports every value copy, and pass such structs by pointer.\n\n**Diagnose:** 1- `go vet .\u002F...` — `copylocks` reports value copies of lock-bearing structs\n\n→ See [Struct Fields: Tags and Copy Safety](references\u002Fstruct-fields.md) for the `noCopy` implementation and how `vet` detects it.\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-naming` skill for interface naming conventions (Reader, Closer, Stringer)\n- → See `samber\u002Fcc-skills-golang@golang-design-patterns` skill for functional options, constructors, and builder patterns\n- → See `samber\u002Fcc-skills-golang@golang-dependency-injection` skill for DI patterns using interfaces\n- → See `samber\u002Fcc-skills-golang@golang-code-style` skill for value vs pointer function parameters (distinct from receivers)\n- → See `samber\u002Fcc-skills-golang@golang-gopls` skill for safe rename and the `implementInterface` code action — renaming a method or receiver that participates in interface satisfaction updates every call site and refuses a rename that would silently break the interface, which grep\u002Fsed cannot detect\n\n## Common Mistakes\n\n| Mistake | Fix |\n| --- | --- |\n| Large interfaces (5+ methods) | Split into focused 1-3 method interfaces, compose if needed |\n| Defining interfaces in the implementor package | Define where consumed |\n| Returning interfaces from constructors | Return concrete types |\n| Bare type assertions without comma-ok | Always use `v, ok := x.(T)` |\n| Embedding when you only need a few methods | Use a named field and delegate explicitly |\n| Missing field tags on serialized structs | Tag all exported fields in marshaled types |\n| Mixing pointer and value receivers on a type | Pick one and be consistent |\n| Forgetting compile-time interface check | Add `var _ Interface = (*Type)(nil)` |\n| Using `ToString()` instead of `String()` | Honor canonical method names |\n| Premature interface with a single implementation | Start concrete, extract interface when needed |\n| Nil map\u002Fslice in zero value struct | Use lazy initialization in methods |\n| Using `any` for type-safe operations | Use generics (`[T comparable]`) instead |\n",{"name":5,"paths":24,"license":15,"metadata":26,"description":7,"allowed-tools":36,"compatibility":37,"user-invocable":38},[25],"**\u002F*.go",{"author":27,"version":28,"openclaw":29},"samber","1.2.1",{"emoji":30,"install":31,"homepage":32,"requires":33},"🧩",[],"https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang",{"bins":34},[35],"go","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestion","Designed for Claude Code, Codex or similar harness, and for projects using Golang.",true,"master","fd76f882a04e445e899d5cfb2732f2105ea054ee","skills\u002Fmarketplace\u002Fgolang-structs-interfaces",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":50,"prompt":60,"zipAvailable":38},[51,54,57],{"tool":52,"command":53},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill golang-structs-interfaces",{"tool":55,"command":56},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill golang-structs-interfaces",{"tool":58,"command":59},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill golang-structs-interfaces","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fgolang-structs-interfaces\u002FSKILL.md",[62],{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"skill-report.json","REFERENCE","参考文档",73658,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fgolang-structs-interfaces\u002Fskill-report.json",[69,77,84,91,98,105],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":76},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":76},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":76},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":76},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":76},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":76},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]