{"id":"7862a231-64f1-42a8-964b-37c10dded044","shortId":"yE9q6u","kind":"skill","title":"golang-structs-interfaces","tagline":"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 in","description":"**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/cc-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/cc-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// 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// 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// Good — accepts interface, returns concrete\nfunc NewService(store UserStore) *Service { ... }\n\n// BAD — NEVER return interfaces from constructors\nfunc NewService(store UserStore) ServiceInterface { ... }\n```\n\n### Don't Create Interfaces Prematurely\n\n> \"Don't design with interfaces, discover them.\"\n\nNEVER create interfaces prematurely — wait for 2+ implementations or a testability requirement. Premature interfaces add indirection without value. Start with concrete types; extract an interface when a second consumer or a test mock demands it.\n\n```go\n// 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// 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// Good — zero value is ready to use\nvar buf bytes.Buffer\nbuf.WriteString(\"hello\")\n\nvar mu sync.Mutex\nmu.Lock()\n\n// Bad — zero value is broken, requires constructor\ntype Registry struct {\n    items map[string]Item // nil map, panics on write\n}\n\n// 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` / `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// Bad — loses type safety\nfunc Contains(slice []any, target any) bool { ... }\n\n// 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/http`      | `ServeHTTP(ResponseWriter, *Request)` |\n| `Marshaler`   | `encoding/json` | `MarshalJSON() ([]byte, error)`       |\n| `Unmarshaler` | `encoding/json` | `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\n### Safe Type Assertion\n\nType assertions MUST use the comma-ok form to avoid panics:\n\n```go\n// Good — safe\ns, ok := val.(string)\nif !ok {\n    // handle\n}\n\n// Bad — panics if val is not a string\ns := val.(string)\n```\n\n### Type Switch\n\nDiscover the dynamic type of an interface value:\n\n```go\nswitch v := val.(type) {\ncase string:\n    fmt.Println(v)\ncase int:\n    fmt.Println(v * 2)\ncase io.Reader:\n    io.Copy(os.Stdout, v)\ndefault:\n    fmt.Printf(\"unexpected type %T\\n\", v)\n}\n```\n\n### Optional Behavior with Type Assertions\n\nCheck if a value supports additional capabilities without requiring them upfront:\n\n```go\ntype Flusher interface {\n    Flush() error\n}\n\nfunc writeData(w io.Writer, data []byte) error {\n    if _, err := w.Write(data); err != nil {\n        return err\n    }\n    // Flush only if the writer supports it\n    if f, ok := w.(Flusher); ok {\n        return f.Flush()\n    }\n    return nil\n}\n```\n\nThis pattern is used extensively in the standard library (e.g., `http.Flusher`, `io.ReaderFrom`).\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// 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// Embed — Server exposes all http.Handler methods\ntype Server struct {\n    http.Handler\n}\n\n// 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\nUse field tags for serialization control. Exported fields in serialized structs MUST have field tags:\n\n```go\ntype Order struct {\n    ID        string    `json:\"id\"         db:\"id\"`\n    UserID    string    `json:\"user_id\"    db:\"user_id\"`\n    Total     float64   `json:\"total\"      db:\"total\"`\n    Items     []Item    `json:\"items\"      db:\"-\"`\n    CreatedAt time.Time `json:\"created_at\" db:\"created_at\"`\n    DeletedAt time.Time `json:\"-\"          db:\"deleted_at\"`\n    Internal  string    `json:\"-\"          db:\"-\"`\n}\n```\n\n| Directive               | Meaning                                     |\n| ----------------------- | ------------------------------------------- |\n| `json:\"name\"`           | Field name in JSON output                   |\n| `json:\"name,omitempty\"` | Omit field if zero value                    |\n| `json:\"-\"`              | Always exclude from JSON                    |\n| `json:\",string\"`        | Encode number/bool as JSON string           |\n| `db:\"column\"`           | Database column mapping (sqlx, etc.)        |\n| `yaml:\"name\"`           | YAML field name                             |\n| `xml:\"name,attr\"`       | XML attribute                               |\n| `validate:\"required\"`   | Struct validation (go-playground/validator) |\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\nSome structs must never be copied after first use (e.g., those containing a mutex, a channel, or internal pointers). Embed a `noCopy` sentinel to make `go vet` catch accidental copies:\n\n```go\n// noCopy may be added to structs which must not be copied after first use.\n// See https://pkg.go.dev/sync#noCopy\ntype noCopy struct{}\n\nfunc (*noCopy) Lock()   {}\nfunc (*noCopy) Unlock() {}\n\ntype ConnPool struct {\n    noCopy noCopy\n    mu     sync.Mutex\n    conns  []*Conn\n}\n```\n\n`go vet` reports an error if a `ConnPool` value is copied (passed by value, assigned, etc.). This is the same technique the standard library uses for `sync.WaitGroup`, `sync.Mutex`, `strings.Builder`, and others.\n\nAlways pass these structs by pointer:\n\n```go\n// Good\nfunc process(pool *ConnPool) { ... }\n\n// Bad — go vet will flag this\nfunc process(pool ConnPool) { ... }\n```\n\n## Cross-References\n\n- → See `samber/cc-skills-golang@golang-naming` skill for interface naming conventions (Reader, Closer, Stringer)\n- → See `samber/cc-skills-golang@golang-design-patterns` skill for functional options, constructors, and builder patterns\n- → See `samber/cc-skills-golang@golang-dependency-injection` skill for DI patterns using interfaces\n- → See `samber/cc-skills-golang@golang-code-style` skill for value vs pointer function parameters (distinct from receivers)\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/slice in zero value struct | Use lazy initialization in methods |\n| Using `any` for type-safe operations | Use generics (`[T comparable]`) instead |","tags":["golang","structs","interfaces","skills","samber","agent","agent-skills","antigravity","claude","claude-code","code","codex"],"capabilities":["skill","source-samber","skill-golang-structs-interfaces","topic-agent","topic-agent-skills","topic-antigravity","topic-claude","topic-claude-code","topic-code","topic-codex","topic-coding","topic-copilot","topic-cursor","topic-gemini","topic-gemini-cli-extension"],"categories":["cc-skills-golang"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/samber/cc-skills-golang/golang-structs-interfaces","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add samber/cc-skills-golang","source_repo":"https://github.com/samber/cc-skills-golang","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 1725 github stars · SKILL.md body (11,987 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:53:03.226Z","embedding":null,"createdAt":"2026-04-18T20:32:16.547Z","updatedAt":"2026-05-18T18:53:03.226Z","lastSeenAt":"2026-05-18T18:53:03.226Z","tsv":"'-3':109,1425 '/sync#nocopy':1283 '/validator':1147 '1':108,1424 '1.18':512 '2':345,748 '5':1419 '8080':872 'abstract':67,102 'accept':263,269,307,977 'access':283 'accessor':1192 'accident':1263 'across':1214 'ad':1269 'add':353,1507 'addit':771 'addr':857,871,875 'alreadi':1206 'alway':1112,1333,1454 'api':918 'assert':14,686,691,693,765,1449 'assign':296,658,1316 'attr':1137 'attribut':1139 'avoid':218,501,702 'bad':316,375,456,540,714,1345 'bare':1447 'basic':1177 'behavior':762 'belong':196 'bigger':96 'blank':656 'bodi':239 'boilerpl':432 'bool':550,564 'boundari':528 'broken':460 'buf':448 'buf.writestring':450 'bug':438 'build':682 'builder':1383 'builtin':599 'byte':152,162,576,585,610,615,788 'bytes.buffer':449 'caller':280 'canon':144,617,1518 'capabl':772 'case':740,744,749 'catch':1262 'channel':1250 'check':644,766,1506 'clariti':64,279 'client':253 'close':592 'closer':590,1369 'code':1401 'column':1124,1126 'comma':698,1452 'comma-ok':697,1451 'common':1413 'communiti':70 'compani':73 'compar':559,1554 'compil':641,652,1503 'compile-tim':640,1502 'compon':985 'compos':53,119,126,167,176,1428 'composit':11,845 'concret':56,252,276,310,359,399,1445,1528 'conn':1300,1301 'connpool':1294,1309,1344,1354 'consist':1193,1213,1500 'constructor':321,431,462,982,1381,1443 'consum':194,198,204,211,292,367,1439 'contain':545,557,1170,1246 'context.context':387,996 'contract':125,216 'control':213,1037 'convent':140,1367 'copi':1232,1240,1264,1276,1312 'cost':671 'creat':329,340,1079,1082 'createdat':1076 'cross':1356 'cross-refer':1355 'ctx':386,995 'data':787,793 'databas':1027,1125 'datastor':972 'db':395,409,1055,1062,1069,1075,1081,1087,1093,1123 'decod':537 'decoupl':984 'default':71,754 'defin':38,189,202,229,895,1431,1437 'definit':664 'deleg':1473 'delet':1088 'deletedat':1084 'demand':372 'depend':19,944,973,978,1389 'design':9,35,49,60,90,334,416,427,1375 'di':1393 'direct':1094 'discov':337,727 'distinct':1410 'doesn':256,963 'dynam':729 'e.g':535,824,1244 'easier':114 'email':248 'emb':905,911,946,1254 'embed':12,829,831,832,1460 'encod':1118 'encoding/json':608,613 'enhanc':928 'er':142 'err':155,165,579,588,791,794,797 'error':156,166,241,391,580,589,593,598,600,611,616,782,789,1000,1306 'etc':1129,1317 'ever':677 'exclud':1113 'explicit':76,422,1474 'export':250,1038,1483 'expos':948,965 'extens':819 'extract':361,400,1529 'f':806 'f.flush':812 'fail':683 'favor':51 'field':24,289,840,908,931,957,1030,1033,1039,1045,1098,1107,1133,1471,1476,1484 'findbyid':385,994 'first':1242,1278 'fix':1416 'flag':1349 'flexibl':273 'float64':1066 'flush':781,798 'flusher':779,809 'fmt':595 'fmt.printf':755 'fmt.println':742,746 'fmt.stringer':633 'focus':1423 'forget':1501 'form':700 'full':282,917 'func':311,322,482,544,556,783,1006,1287,1290,1341,1351 'function':267,1204,1379,1408 'generic':515,552,1552 'genuin':533 'get':281 'go':36,46,86,103,146,182,226,305,374,439,511,539,665,704,735,777,848,945,990,1047,1145,1260,1265,1302,1339,1346 'go-playground':1144 'golang':2,5,80,134,1361,1374,1388,1400 'golang-code-styl':1399 'golang-dependency-inject':1387 'golang-design-pattern':1373 'golang-nam':133,1360 'golang-structs-interfac':1,79 'good':306,397,440,475,551,705,1340 'guard':478 'handl':713 'handler':602 'hello':451 'honor':622,1517 'http.flusher':825 'http.handler':950,955 'id':388,997,1051,1054,1056,1061,1064 'identifi':657 'immedi':684 'immut':1168 'implement':40,116,207,346,381,648,1526 'implementor':1435 'import':219 'indirect':354 'inherit':847 'initi':423,477,1541 'inject':20,974,1390 'inner':835,884,921,936 'instead':1514,1555 'int':154,164,578,587,745,1179 'interfac':4,8,17,22,54,82,88,89,93,98,105,112,130,138,149,159,170,173,178,185,190,195,199,225,236,264,270,301,308,319,330,336,341,352,363,377,384,402,503,568,569,643,650,733,780,828,976,980,993,1365,1396,1418,1427,1432,1441,1505,1509,1522,1530 'intern':938,1090,1252 'invent':636 'io':573,582,591 'io.closer':188 'io.copy':751 'io.reader':186,750 'io.readerfrom':826 'io.readwriter':667,680 'io.writer':187,786 'item':466,469,488,489,497,500,1071,1072,1074 'json':536,1053,1059,1067,1073,1078,1086,1092,1096,1101,1103,1111,1115,1116,1121 'keep':92,209 'key':565 'know':260 'larg':1184,1417 'larger':124,177 'later':403 'lazi':476,1540 'librari':567,823,1325 'lock':1289 'logger':850,856,865,868,869 'lose':541 'make':411,494,987,1259 'map':467,471,495,1127,1202 'map/slice':1534 'marshal':607,1486 'marshaljson':609 'match':632 'may':1267 'mean':1095 'method':110,141,291,571,618,629,838,881,898,951,967,1160,1186,1196,1216,1222,1228,1420,1426,1467,1519,1543 'miss':1475 'mistak':1414,1415 'mix':1488 'mock':117,371,1019 'modifi':1161 'mu':453,1298 'mu.lock':455 'must':200,513,620,631,694,1043,1211,1237,1273 'mutex':1248 'mybuff':668,676 'n':153,163,577,586,759 'name':135,139,145,486,499,902,907,930,956,1097,1099,1104,1131,1134,1136,1362,1366,1470,1520 'near':661 'need':122,233,258,304,405,934,1028,1430,1464,1532 'net/http':603 'never':317,339,1238 'newservic':312,323 'newuserservic':1007 'nil':436,470,492,669,795,814,1511,1533 'nil-rel':435 'nocopi':1234,1256,1266,1285,1288,1291,1296,1297 'noth':672 'notif':228 'number/bool':1119 'ok':699,708,712,807,810,1453,1457 'omit':1106 'omitempti':1105 'one':181,1221,1497 'oper':522,1550 'option':761,1380 'order':1049 'os.stdout':752 'other':1332 'outer':843,888,890,924,940 'output':1102 'overrid':893 'p':151,161,575,584 'packag':221,227,249,570,1436 'panic':472,703,715 'paramet':271,1409 'pass':1017,1313,1334 'pattern':10,816,1376,1384,1394 'persona':42 'pick':1496 'pkg.go.dev':1282 'pkg.go.dev/sync#nocopy':1281 'place':659 'playground':1146 'pointer':27,1148,1153,1199,1225,1253,1338,1407,1489 'pool':1343,1353 'preced':85 'prefer':514 'prematur':331,342,351,376,1521 'prevent':434,1230 'principl':91 'process':1342,1352 'promot':833,861,880,915 'proverb':104 'r':483 'r.items':491,493,498 're':193 'read':150,574,1190 'read-on':1189 'readdata':639 'reader':148,174,572,1368 'readi':444 'readwrit':172 'readwriteclos':184 'real':1026 'receiv':30,878,1151,1163,1164,1169,1174,1181,1209,1226,1412,1492 'reduc':430 'refer':1207,1357 'reflect':538 'regist':485 'registri':464,484 'relat':437 'report':1304 'request':606 'requir':350,461,774,1141 'responsewrit':605 'result':298 'return':57,265,275,286,309,318,796,811,813,1011,1440,1444 'runtim':674 's.addr':876 's.info':859,873 'safe':521,555,689,706,1549 'safeti':543 'sake':69 'samber/cc-skills-golang':78,132,1359,1372,1386,1398 'satisfi':679,1023 'second':366 'see':131,1280,1358,1371,1385,1397 'segreg':18 'send':237 'sender':235,245,246,262 'sentinel':1257 'serial':1036,1041,1479 'servehttp':604 'server':854,867,947,953,958,969,1155,1159 'servic':243,315 'serviceinterfac':326 'signatur':619 'similar':1173 'sinc':510 'singl':380,1525 'skill':33,74,83,136,1363,1377,1391,1403 'skill-golang-structs-interfaces' 'slice':546,560 'slog.default':870 'slog.logger':852,863 'small':52,94,111,129,169,1166 'smaller':180 'source-samber' 'specif':506 'split':1421 'sql.db':396,410 'sqlx':1128 'standard':566,822,1324 'start':357,398,874,1527 'still':295 'stop':678 'store':313,324,961,971,1004,1008,1013,1014 'straightforward':989 'string':240,389,468,487,496,596,597,601,628,710,721,724,741,858,998,1052,1058,1091,1117,1122,1180,1516 'stringer':594,1370 'strings.builder':1330 'struct':3,6,23,81,87,244,254,266,394,408,417,465,827,830,851,855,954,970,1003,1029,1042,1050,1142,1185,1231,1236,1271,1286,1295,1336,1480,1538 'stub':1021 'style':1402 'suffix':143 'supersed':77 'support':770,803 'switch':16,688,726,736 'sync.mutex':454,1171,1299,1329 'sync.waitgroup':1328 'system':48 'tag':25,1031,1034,1046,1477,1481 'take':84 'target':548,562 'techniqu':1322 'test':370,988,1016 'testabl':62,349 'time':642,653,1504 'time.time':1077,1085 'topic-agent' 'topic-agent-skills' 'topic-antigravity' 'topic-claude' 'topic-claude-code' 'topic-code' 'topic-codex' 'topic-coding' 'topic-copilot' 'topic-cursor' 'topic-gemini' 'topic-gemini-cli-extension' 'tostr':637,1513 'total':1065,1068,1070 'true':527 'type':13,15,37,47,58,147,157,171,183,234,242,277,287,360,382,392,406,463,507,520,531,542,554,625,647,663,685,687,690,692,725,730,739,757,764,778,836,844,849,853,885,891,922,925,937,941,952,968,991,1001,1048,1178,1208,1210,1219,1284,1293,1446,1448,1487,1495,1510,1548 'type-saf':519,553,1547 'unexpect':756 'unknown':534 'unlock':1292 'unmarshal':612 'unmarshaljson':614 'upfront':776 'upstream':293 'use':31,415,446,523,695,818,909,959,1032,1152,1156,1197,1223,1243,1279,1326,1395,1455,1468,1512,1539,1544,1551 'user':390,999,1060,1063 'userid':1057 'userrepositori':383,393,407 'userservic':1002,1010,1012 'userstor':314,325,992,1005,1009,1024 'v':737,743,747,753,760,1456 'val':709,717,723,738 'valid':1140,1143 'valu':29,356,414,429,442,458,481,734,769,1110,1150,1157,1205,1310,1315,1405,1491,1537 'var':447,452,666,1508 'variabl':302 'verifi':645 'version':929 'vet':1261,1303,1347 'via':21,975 'vs':28,906,1149,1406 'w':785,808 'w.write':792 'wait':343 'want':913 'weaker':100 'well':426 'well-design':425 'without':355,421,773,1450 'work':420,860 'write':160,474,583 'writedata':784 'writer':158,175,581,802 'x':1458 'xml':1135,1138 'yaml':1130,1132 'zero':413,428,441,457,480,1109,1536","prices":[{"id":"c941a096-3ec3-47cc-974f-beb80135c862","listingId":"7862a231-64f1-42a8-964b-37c10dded044","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"samber","category":"cc-skills-golang","install_from":"skills.sh"},"createdAt":"2026-04-18T20:32:16.547Z"}],"sources":[{"listingId":"7862a231-64f1-42a8-964b-37c10dded044","source":"github","sourceId":"samber/cc-skills-golang/golang-structs-interfaces","sourceUrl":"https://github.com/samber/cc-skills-golang/tree/main/skills/golang-structs-interfaces","isPrimary":false,"firstSeenAt":"2026-04-18T21:55:24.758Z","lastSeenAt":"2026-05-18T18:53:03.226Z"},{"listingId":"7862a231-64f1-42a8-964b-37c10dded044","source":"skills_sh","sourceId":"samber/cc-skills-golang/golang-structs-interfaces","sourceUrl":"https://skills.sh/samber/cc-skills-golang/golang-structs-interfaces","isPrimary":true,"firstSeenAt":"2026-04-18T20:32:16.547Z","lastSeenAt":"2026-05-07T22:40:27.453Z"}],"details":{"listingId":"7862a231-64f1-42a8-964b-37c10dded044","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"samber","slug":"golang-structs-interfaces","github":{"repo":"samber/cc-skills-golang","stars":1725,"topics":["agent","agent-skills","ai","antigravity","claude","claude-code","code","codex","coding","copilot","cursor","gemini","gemini-cli-extension","openclaw","opencode","plugin","skills","skillsmp","vibe-coding"],"license":"mit","html_url":"https://github.com/samber/cc-skills-golang","pushed_at":"2026-05-18T17:36:00Z","description":"🧑‍🎨 A collection of Golang agentic skills that works","skill_md_sha":"09f36b4d3c33ab7f3dc7cab54c867151363251e4","skill_md_path":"skills/golang-structs-interfaces/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/samber/cc-skills-golang/tree/main/skills/golang-structs-interfaces"},"layout":"multi","source":"github","category":"cc-skills-golang","frontmatter":{"name":"golang-structs-interfaces","license":"MIT","description":"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/YAML/DB 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.","compatibility":"Designed for Claude Code or similar AI coding agents, and for projects using Golang."},"skills_sh_url":"https://skills.sh/samber/cc-skills-golang/golang-structs-interfaces"},"updatedAt":"2026-05-18T18:53:03.226Z"}}