[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F3H0ZETCZ68ZF717DBK6AT":3,"skill-same:01M6F3H0ZETCZ68ZF717DBK6AT":69},{"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":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":51,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M6F3H0ZETCZ68ZF717DBK6AT","go-control-flow",null,"Use when writing conditionals, loops, or switch statements in Go — including if with initialization, early returns, for loop forms, range, switch, type switches, and blank identifier patterns. Also use when writing a simple if\u002Felse or for loop, even if the user doesn't mention guard clauses or variable scoping. Does not cover error flow patterns (see go-error-handling).","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-control-flow\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"go control flow","go","flow","control","switch","with","loops","error","style","type","forms","patterns","writing","simple","error-handling","use","Effective Go","loop","guard","google","2026-11-10 10:12:30",false,"---\nname: go-control-flow\ndescription: Use when writing conditionals, loops, or switch statements in Go — including if with initialization, early returns, for loop forms, range, switch, type switches, and blank identifier patterns. Also use when writing a simple if\u002Felse or for loop, even if the user doesn't mention guard clauses or variable scoping. Does not cover error flow patterns (see go-error-handling).\nlicense: Apache-2.0\nmetadata:\n  sources: \"Effective Go, Google Style Guide\"\n---\n\n# Go Control Flow\n\n> Read [references\u002FSWITCH-PATTERNS.md](references\u002FSWITCH-PATTERNS.md) when using switch statements, type switches, or break with labels\n\n> Read [references\u002FBLANK-IDENTIFIER.md](references\u002FBLANK-IDENTIFIER.md) when using `_`, blank identifier imports, or compile-time interface checks\n\n---\n\n## If with Initialization\n\n`if` and `switch` accept an optional initialization statement. Use it to scope\nvariables to the conditional block:\n\n```go\nif err := file.Chmod(0664); err != nil {\n    log.Print(err)\n    return err\n}\n```\n\nIf you need the variable beyond a few lines after the `if`, declare it\nseparately and use a standard `if` instead:\n\n```go\nx, err := f()\nif err != nil {\n    return err\n}\n\u002F\u002F lots of code that uses x\n```\n\n## Indent Error Flow (Guard Clauses)\n\nWhen an `if` body ends with `break`, `continue`, `goto`, or `return`, omit the\nunnecessary `else`. Keep the success path unindented:\n\n```go\nf, err := os.Open(name)\nif err != nil {\n    return err\n}\nd, err := f.Stat()\nif err != nil {\n    f.Close()\n    return err\n}\ncodeUsing(f, d)\n```\n\nNever bury normal flow inside an `else` when the `if` already returns.\n\n---\n\n## Redeclaration and Reassignment\n\nThe `:=` short declaration allows redeclaring variables in the same scope:\n\n```go\nf, err := os.Open(name)  \u002F\u002F declares f and err\nd, err := f.Stat()       \u002F\u002F declares d, reassigns err\n```\n\nA variable `v` may appear in a `:=` declaration even if already declared,\nprovided:\n\n1. The declaration is in the **same scope** as the existing `v`\n2. The value is **assignable** to `v`\n3. At least **one other variable** is newly created by the declaration\n\n### Variable Shadowing\n\n**Warning**: If `v` is declared in an outer scope, `:=` creates a **new**\nvariable that shadows it — a common source of bugs:\n\n```go\n\u002F\u002F Bug: ctx inside the if block shadows the outer ctx\nif *shortenDeadlines {\n    ctx, cancel := context.WithTimeout(ctx, 3*time.Second)\n    defer cancel()\n}\n\u002F\u002F ctx here is still the original — the shadowed ctx didn't escape\n\n\u002F\u002F Fix: use = instead of :=\nvar cancel func()\nctx, cancel = context.WithTimeout(ctx, 3*time.Second)\n```\n\n---\n\n## For Loops\n\nGo's `for` is its only looping construct, unifying `while`, `do-while`, and\nC-style `for`:\n\n```go\n\u002F\u002F Condition-only (Go's \"while\")\nfor x > 0 {\n    x = process(x)\n}\n\n\u002F\u002F Infinite loop\nfor {\n    if done() { break }\n}\n\n\u002F\u002F C-style three-component\nfor i := 0; i \u003C n; i++ { ... }\n```\n\n### Range\n\n`range` iterates over slices, maps, strings, and channels:\n\n```go\nfor i, v := range slice { ... }   \u002F\u002F index + value\nfor k, v := range myMap { ... }   \u002F\u002F key + value (non-deterministic order)\nfor i, r := range \"héllo\" { ... } \u002F\u002F byte index + rune (not byte)\nfor v := range ch { ... }         \u002F\u002F receives until channel closed\n```\n\n**Key rules:**\n- Range over strings yields **runes**, not bytes — `i` is the byte offset\n- Range over maps has **non-deterministic order** — don't rely on it\n- Use `_` to discard the index or value: `for _, v := range slice`\n\n### Parallel Assignment\n\nGo has no comma operator. Use parallel assignment for multiple loop variables:\n\n```go\nfor i, j := 0, len(a)-1; i \u003C j; i, j = i+1, j-1 {\n    a[i], a[j] = a[j], a[i]\n}\n```\n\n`++` and `--` are statements, not expressions — they cannot appear in parallel\nassignment.\n\n---\n\n## Switch: Labeled Break\n\n`break` inside a `switch` within a `for` loop only breaks the switch.\nUse a labeled `break` to exit the enclosing loop:\n\n```go\nLoop:\n    for _, v := range items {\n        switch v.Type {\n        case \"done\":\n            break Loop  \u002F\u002F breaks the for loop\n        }\n    }\n```\n\nFor type switches, see **go-interfaces**: Type Switch.\n\n---\n\n## The Blank Identifier\n\n**Never discard errors carelessly** — a nil dereference panic may follow.\n\nVerify interface compliance at compile time: `var _ io.Writer = (*MyType)(nil)`.\nSee **go-interfaces** for the interface satisfaction check pattern.\n\n---\n\n## Quick Reference\n\n| Pattern | Go Idiom |\n|---------|----------|\n| If initialization | `if err := f(); err != nil { }` |\n| Early return | Omit `else` when if body returns |\n| Redeclaration | `:=` reassigns if same scope + new var |\n| Shadowing trap | `:=` in inner scope creates new variable |\n| Parallel assignment | `i, j = i+1, j-1` |\n| Expression-less switch | `switch { case cond: }` |\n| Comma cases | `case 'a', 'b', 'c':` |\n| No fallthrough | Default behavior (explicit `fallthrough` if needed) |\n| Break from loop in switch | `break Label` |\n| Discard value | `_, err := f()` |\n| Side-effect import | `import _ \"pkg\"` |\n| Interface check | `var _ Interface = (*Type)(nil)` |\n\n---\n\n## Related Skills\n\n- **Error flow**: See [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) when structuring guard clauses, early returns, or error-first patterns\n- **Type switches**: See [go-interfaces](..\u002Fgo-interfaces\u002FSKILL.md) when using type switches, the comma-ok idiom, or interface satisfaction checks\n- **Nesting reduction**: See [go-style-core](..\u002Fgo-style-core\u002FSKILL.md) when reducing nesting depth or resolving formatting questions\n- **Variable scoping**: See [go-declarations](..\u002Fgo-declarations\u002FSKILL.md) when using if-init, `:=` redeclaration, or reducing variable scope\n\n","# Go Control Flow\n\n> Read [references\u002FSWITCH-PATTERNS.md](references\u002FSWITCH-PATTERNS.md) when using switch statements, type switches, or break with labels\n\n> Read [references\u002FBLANK-IDENTIFIER.md](references\u002FBLANK-IDENTIFIER.md) when using `_`, blank identifier imports, or compile-time interface checks\n\n---\n\n## If with Initialization\n\n`if` and `switch` accept an optional initialization statement. Use it to scope\nvariables to the conditional block:\n\n```go\nif err := file.Chmod(0664); err != nil {\n    log.Print(err)\n    return err\n}\n```\n\nIf you need the variable beyond a few lines after the `if`, declare it\nseparately and use a standard `if` instead:\n\n```go\nx, err := f()\nif err != nil {\n    return err\n}\n\u002F\u002F lots of code that uses x\n```\n\n## Indent Error Flow (Guard Clauses)\n\nWhen an `if` body ends with `break`, `continue`, `goto`, or `return`, omit the\nunnecessary `else`. Keep the success path unindented:\n\n```go\nf, err := os.Open(name)\nif err != nil {\n    return err\n}\nd, err := f.Stat()\nif err != nil {\n    f.Close()\n    return err\n}\ncodeUsing(f, d)\n```\n\nNever bury normal flow inside an `else` when the `if` already returns.\n\n---\n\n## Redeclaration and Reassignment\n\nThe `:=` short declaration allows redeclaring variables in the same scope:\n\n```go\nf, err := os.Open(name)  \u002F\u002F declares f and err\nd, err := f.Stat()       \u002F\u002F declares d, reassigns err\n```\n\nA variable `v` may appear in a `:=` declaration even if already declared,\nprovided:\n\n1. The declaration is in the **same scope** as the existing `v`\n2. The value is **assignable** to `v`\n3. At least **one other variable** is newly created by the declaration\n\n### Variable Shadowing\n\n**Warning**: If `v` is declared in an outer scope, `:=` creates a **new**\nvariable that shadows it — a common source of bugs:\n\n```go\n\u002F\u002F Bug: ctx inside the if block shadows the outer ctx\nif *shortenDeadlines {\n    ctx, cancel := context.WithTimeout(ctx, 3*time.Second)\n    defer cancel()\n}\n\u002F\u002F ctx here is still the original — the shadowed ctx didn't escape\n\n\u002F\u002F Fix: use = instead of :=\nvar cancel func()\nctx, cancel = context.WithTimeout(ctx, 3*time.Second)\n```\n\n---\n\n## For Loops\n\nGo's `for` is its only looping construct, unifying `while`, `do-while`, and\nC-style `for`:\n\n```go\n\u002F\u002F Condition-only (Go's \"while\")\nfor x > 0 {\n    x = process(x)\n}\n\n\u002F\u002F Infinite loop\nfor {\n    if done() { break }\n}\n\n\u002F\u002F C-style three-component\nfor i := 0; i \u003C n; i++ { ... }\n```\n\n### Range\n\n`range` iterates over slices, maps, strings, and channels:\n\n```go\nfor i, v := range slice { ... }   \u002F\u002F index + value\nfor k, v := range myMap { ... }   \u002F\u002F key + value (non-deterministic order)\nfor i, r := range \"héllo\" { ... } \u002F\u002F byte index + rune (not byte)\nfor v := range ch { ... }         \u002F\u002F receives until channel closed\n```\n\n**Key rules:**\n- Range over strings yields **runes**, not bytes — `i` is the byte offset\n- Range over maps has **non-deterministic order** — don't rely on it\n- Use `_` to discard the index or value: `for _, v := range slice`\n\n### Parallel Assignment\n\nGo has no comma operator. Use parallel assignment for multiple loop variables:\n\n```go\nfor i, j := 0, len(a)-1; i \u003C j; i, j = i+1, j-1 {\n    a[i], a[j] = a[j], a[i]\n}\n```\n\n`++` and `--` are statements, not expressions — they cannot appear in parallel\nassignment.\n\n---\n\n## Switch: Labeled Break\n\n`break` inside a `switch` within a `for` loop only breaks the switch.\nUse a labeled `break` to exit the enclosing loop:\n\n```go\nLoop:\n    for _, v := range items {\n        switch v.Type {\n        case \"done\":\n            break Loop  \u002F\u002F breaks the for loop\n        }\n    }\n```\n\nFor type switches, see **go-interfaces**: Type Switch.\n\n---\n\n## The Blank Identifier\n\n**Never discard errors carelessly** — a nil dereference panic may follow.\n\nVerify interface compliance at compile time: `var _ io.Writer = (*MyType)(nil)`.\nSee **go-interfaces** for the interface satisfaction check pattern.\n\n---\n\n## Quick Reference\n\n| Pattern | Go Idiom |\n|---------|----------|\n| If initialization | `if err := f(); err != nil { }` |\n| Early return | Omit `else` when if body returns |\n| Redeclaration | `:=` reassigns if same scope + new var |\n| Shadowing trap | `:=` in inner scope creates new variable |\n| Parallel assignment | `i, j = i+1, j-1` |\n| Expression-less switch | `switch { case cond: }` |\n| Comma cases | `case 'a', 'b', 'c':` |\n| No fallthrough | Default behavior (explicit `fallthrough` if needed) |\n| Break from loop in switch | `break Label` |\n| Discard value | `_, err := f()` |\n| Side-effect import | `import _ \"pkg\"` |\n| Interface check | `var _ Interface = (*Type)(nil)` |\n\n---\n\n## Related Skills\n\n- **Error flow**: See [go-error-handling](..\u002Fgo-error-handling\u002FSKILL.md) when structuring guard clauses, early returns, or error-first patterns\n- **Type switches**: See [go-interfaces](..\u002Fgo-interfaces\u002FSKILL.md) when using type switches, the comma-ok idiom, or interface satisfaction checks\n- **Nesting reduction**: See [go-style-core](..\u002Fgo-style-core\u002FSKILL.md) when reducing nesting depth or resolving formatting questions\n- **Variable scoping**: See [go-declarations](..\u002Fgo-declarations\u002FSKILL.md) when using if-init, `:=` redeclaration, or reducing variable scope\n\n",{"name":5,"license":15,"metadata":44,"description":7},{"sources":45},"Effective Go, Google Style Guide","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fcxuu\u002Fgolang-skills\u002Fgo-control-flow",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":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill go-control-flow",{"tool":61,"command":62},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill go-control-flow",{"tool":64,"command":65},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill go-control-flow","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fcxuu\u002Fgolang-skills\u002Fgo-control-flow\u002FSKILL.md",true,[],[70,80,89,98,104,110],{"skillNo":71,"name":72,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"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",[],[77,78,79],"model","model hierarchy","model hierarchy skill",{"skillNo":81,"name":82,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[86,87,88],"MCP","zoom","zoom mcp",{"skillNo":90,"name":91,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[95,96,97,87],"sdk","zoom apps sdk","apps",{"skillNo":99,"name":100,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[100],{"skillNo":105,"name":106,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[106],{"skillNo":111,"name":112,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":73,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[112]]