[{"data":1,"prerenderedAt":944},["ShallowReactive",2],{"navigation_docs":3,"-concurrency-goroutines":377,"-concurrency-goroutines-surround":939},[4,39,114,144,184,244,293,362],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":6},"Getting Started",false,"\u002Fgetting-started","1.getting-started",[10,15,20,25,30,35],{"title":11,"path":12,"stem":13,"icon":14},"Learning Path","\u002Fgetting-started\u002Flearning-path","1.getting-started\u002F1.learning-path","i-lucide-map",{"title":16,"path":17,"stem":18,"icon":19},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F2.introduction","i-lucide-house",{"title":21,"path":22,"stem":23,"icon":24},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F3.installation","i-lucide-download",{"title":26,"path":27,"stem":28,"icon":29},"Your First Program","\u002Fgetting-started\u002Ffirst-program","1.getting-started\u002F4.first-program","i-lucide-play",{"title":31,"path":32,"stem":33,"icon":34},"Modules and Dependencies","\u002Fgetting-started\u002Fmodules-and-dependencies","1.getting-started\u002F5.modules-and-dependencies","i-lucide-package-open",{"title":36,"path":37,"stem":38,"icon":34},"Advanced Modules","\u002Fgetting-started\u002Fadvanced-modules","1.getting-started\u002F6.advanced-modules",{"title":40,"path":41,"stem":42,"children":43,"page":6},"Fundamentals","\u002Ffundamentals","2.fundamentals",[44,49,54,59,64,69,74,79,84,89,94,99,104,109],{"title":45,"path":46,"stem":47,"icon":48},"Program Structure","\u002Ffundamentals\u002Fprogram-structure","2.fundamentals\u002F1.program-structure","i-lucide-workflow",{"title":50,"path":51,"stem":52,"icon":53},"Structs and Methods","\u002Ffundamentals\u002Fstructs-and-methods","2.fundamentals\u002F10.structs-and-methods","i-lucide-box",{"title":55,"path":56,"stem":57,"icon":58},"Interfaces","\u002Ffundamentals\u002Finterfaces","2.fundamentals\u002F11.interfaces","i-lucide-plug",{"title":60,"path":61,"stem":62,"icon":63},"Error Handling","\u002Ffundamentals\u002Ferrors","2.fundamentals\u002F12.errors","i-lucide-triangle-alert",{"title":65,"path":66,"stem":67,"icon":68},"Defined Types and Type Aliases","\u002Ffundamentals\u002Fdefined-types","2.fundamentals\u002F13.defined-types","i-lucide-tags",{"title":70,"path":71,"stem":72,"icon":73},"Generics","\u002Ffundamentals\u002Fgenerics","2.fundamentals\u002F14.generics","i-lucide-blocks",{"title":75,"path":76,"stem":77,"icon":78},"Project Structure","\u002Ffundamentals\u002Fproject-structure","2.fundamentals\u002F2.project-structure","i-lucide-folder-tree",{"title":80,"path":81,"stem":82,"icon":83},"Project Layout","\u002Ffundamentals\u002Fproject-layout","2.fundamentals\u002F3.project-layout","i-lucide-layout",{"title":85,"path":86,"stem":87,"icon":88},"Variables and Data Types","\u002Ffundamentals\u002Fvariables-and-types","2.fundamentals\u002F4.variables-and-types","i-lucide-variable",{"title":90,"path":91,"stem":92,"icon":93},"Functions","\u002Ffundamentals\u002Ffunctions","2.fundamentals\u002F5.functions","i-lucide-braces",{"title":95,"path":96,"stem":97,"icon":98},"Control Statements","\u002Ffundamentals\u002Fcontrol-statements","2.fundamentals\u002F6.control-statements","i-lucide-git-branch",{"title":100,"path":101,"stem":102,"icon":103},"Pointers","\u002Ffundamentals\u002Fpointers","2.fundamentals\u002F7.pointers","i-lucide-mouse-pointer-2",{"title":105,"path":106,"stem":107,"icon":108},"Arrays and Slices","\u002Ffundamentals\u002Farrays-and-slices","2.fundamentals\u002F8.arrays-and-slices","i-lucide-list",{"title":110,"path":111,"stem":112,"icon":113},"Maps","\u002Ffundamentals\u002Fmaps","2.fundamentals\u002F9.maps","i-lucide-table-properties",{"title":115,"path":116,"stem":117,"children":118,"page":6},"Concurrency","\u002Fconcurrency","3.concurrency",[119,124,129,134,139],{"title":120,"path":121,"stem":122,"icon":123},"Concurrency Model","\u002Fconcurrency\u002Fconcurrency-model","3.concurrency\u002F1.concurrency-model","i-lucide-network",{"title":125,"path":126,"stem":127,"icon":128},"Goroutines","\u002Fconcurrency\u002Fgoroutines","3.concurrency\u002F2.goroutines","i-lucide-git-fork",{"title":130,"path":131,"stem":132,"icon":133},"Channels","\u002Fconcurrency\u002Fchannels","3.concurrency\u002F3.channels","i-lucide-arrow-left-right",{"title":135,"path":136,"stem":137,"icon":138},"Select and Cancellation","\u002Fconcurrency\u002Fselect-and-cancellation","3.concurrency\u002F4.select-and-cancellation","i-lucide-circle-stop",{"title":140,"path":141,"stem":142,"icon":143},"Synchronization","\u002Fconcurrency\u002Fsynchronization","3.concurrency\u002F5.synchronization","i-lucide-lock-keyhole",{"title":145,"path":146,"stem":147,"children":148,"page":6},"Standard Library","\u002Fstandard-library","4.standard-library",[149,154,159,164,169,174,179],{"title":150,"path":151,"stem":152,"icon":153},"Standard Library Overview","\u002Fstandard-library\u002Foverview","4.standard-library\u002F1.overview","i-lucide-library",{"title":155,"path":156,"stem":157,"icon":158},"Text and Formatting","\u002Fstandard-library\u002Ftext-and-formatting","4.standard-library\u002F2.text-and-formatting","i-lucide-text",{"title":160,"path":161,"stem":162,"icon":163},"Files and JSON","\u002Fstandard-library\u002Ffiles-and-json","4.standard-library\u002F3.files-and-json","i-lucide-file-json",{"title":165,"path":166,"stem":167,"icon":168},"HTTP Clients and Servers","\u002Fstandard-library\u002Fhttp","4.standard-library\u002F4.http","i-lucide-server",{"title":170,"path":171,"stem":172,"icon":173},"Testing","\u002Fstandard-library\u002Ftesting","4.standard-library\u002F5.testing","i-lucide-flask-conical",{"title":175,"path":176,"stem":177,"icon":178},"Command-Line Tools and Configuration","\u002Fstandard-library\u002Fcommand-line-and-configuration","4.standard-library\u002F6.command-line-and-configuration","i-lucide-terminal-square",{"title":180,"path":181,"stem":182,"icon":183},"Structured Logging","\u002Fstandard-library\u002Fstructured-logging","4.standard-library\u002F7.structured-logging","i-lucide-scroll-text",{"title":185,"path":186,"stem":187,"children":188,"page":6},"Backend Development","\u002Fbackend-development","5.backend-development",[189,194,199,204,209,214,219,224,229,234,239],{"title":190,"path":191,"stem":192,"icon":193},"Backend Roadmap","\u002Fbackend-development\u002Fbackend-roadmap","5.backend-development\u002F1.backend-roadmap","i-lucide-route",{"title":195,"path":196,"stem":197,"icon":198},"Graceful Shutdown","\u002Fbackend-development\u002Fgraceful-shutdown","5.backend-development\u002F10.graceful-shutdown","i-lucide-power",{"title":200,"path":201,"stem":202,"icon":203},"Production Checklist","\u002Fbackend-development\u002Fproduction-checklist","5.backend-development\u002F11.production-checklist","i-lucide-clipboard-check",{"title":205,"path":206,"stem":207,"icon":208},"HTTP API Design","\u002Fbackend-development\u002Fhttp-api-design","5.backend-development\u002F2.http-api-design","i-lucide-waypoints",{"title":210,"path":211,"stem":212,"icon":213},"Middleware","\u002Fbackend-development\u002Fmiddleware","5.backend-development\u002F3.middleware","i-lucide-layers-3",{"title":215,"path":216,"stem":217,"icon":218},"Validation","\u002Fbackend-development\u002Fvalidation","5.backend-development\u002F4.validation","i-lucide-list-checks",{"title":220,"path":221,"stem":222,"icon":223},"Application Wiring","\u002Fbackend-development\u002Fapplication-wiring","5.backend-development\u002F5.application-wiring","i-lucide-cable",{"title":225,"path":226,"stem":227,"icon":228},"Observability","\u002Fbackend-development\u002Fobservability","5.backend-development\u002F6.observability","i-lucide-activity",{"title":230,"path":231,"stem":232,"icon":233},"Database SQL","\u002Fbackend-development\u002Fdatabase-sql","5.backend-development\u002F7.database-sql","i-lucide-database",{"title":235,"path":236,"stem":237,"icon":238},"Transactions","\u002Fbackend-development\u002Ftransactions","5.backend-development\u002F8.transactions","i-lucide-repeat-2",{"title":240,"path":241,"stem":242,"icon":243},"Authentication and Authorization","\u002Fbackend-development\u002Fauthentication","5.backend-development\u002F9.authentication","i-lucide-shield-check",{"title":245,"path":246,"stem":247,"children":248,"page":6},"Advanced Go","\u002Fadvanced-go","6.advanced-go",[249,254,259,264,269,274,278,283,288],{"title":250,"path":251,"stem":252,"icon":253},"Advanced Go Roadmap","\u002Fadvanced-go\u002Fadvanced-roadmap","6.advanced-go\u002F1.advanced-roadmap","i-lucide-brain-circuit",{"title":255,"path":256,"stem":257,"icon":258},"Reflection","\u002Fadvanced-go\u002Freflection","6.advanced-go\u002F2.reflection","i-lucide-scan-search",{"title":260,"path":261,"stem":262,"icon":263},"Memory and Garbage Collection","\u002Fadvanced-go\u002Fmemory-and-garbage-collection","6.advanced-go\u002F3.memory-and-garbage-collection","i-lucide-memory-stick",{"title":265,"path":266,"stem":267,"icon":268},"Benchmarking and Profiling","\u002Fadvanced-go\u002Fbenchmarking-and-profiling","6.advanced-go\u002F4.benchmarking-and-profiling","i-lucide-gauge",{"title":270,"path":271,"stem":272,"icon":273},"Advanced Testing and Fuzzing","\u002Fadvanced-go\u002Fadvanced-testing-and-fuzzing","6.advanced-go\u002F5.advanced-testing-and-fuzzing","i-lucide-microscope",{"title":275,"path":276,"stem":277,"icon":48},"Advanced Concurrency","\u002Fadvanced-go\u002Fadvanced-concurrency","6.advanced-go\u002F6.advanced-concurrency",{"title":279,"path":280,"stem":281,"icon":282},"Unsafe and C Boundaries","\u002Fadvanced-go\u002Funsafe-and-cgo","6.advanced-go\u002F7.unsafe-and-cgo","i-lucide-radiation",{"title":284,"path":285,"stem":286,"icon":287},"Package and API Design","\u002Fadvanced-go\u002Fpackage-and-api-design","6.advanced-go\u002F8.package-and-api-design","i-lucide-boxes",{"title":289,"path":290,"stem":291,"icon":292},"Distributed Reliability","\u002Fadvanced-go\u002Fdistributed-reliability","6.advanced-go\u002F9.distributed-reliability","i-lucide-cloud-cog",{"title":294,"path":295,"stem":296,"children":297,"page":6},"Projects","\u002Fprojects","7.projects",[298,316,332,347],{"title":299,"path":300,"stem":301,"children":302,"icon":305},"CLI Task Manager","\u002Fprojects\u002Fcli-task-manager","7.projects\u002F1.cli-task-manager\u002Findex",[303,306,311],{"title":304,"path":300,"stem":301,"icon":305},"Project — CLI Task Manager","i-lucide-list-todo",{"title":307,"path":308,"stem":309,"icon":310},"CLI — Domain and Storage","\u002Fprojects\u002Fcli-task-manager\u002Fdomain-and-storage","7.projects\u002F1.cli-task-manager\u002F1.domain-and-storage","i-lucide-save",{"title":312,"path":313,"stem":314,"icon":315},"CLI — Commands and Tests","\u002Fprojects\u002Fcli-task-manager\u002Fcommands-and-tests","7.projects\u002F1.cli-task-manager\u002F2.commands-and-tests","i-lucide-terminal",{"title":317,"path":318,"stem":319,"children":320,"icon":323},"Concurrent URL Checker","\u002Fprojects\u002Fconcurrent-url-checker","7.projects\u002F2.concurrent-url-checker\u002Findex",[321,324,328],{"title":322,"path":318,"stem":319,"icon":323},"Project — Concurrent URL Checker","i-lucide-radar",{"title":325,"path":326,"stem":327,"icon":128},"URL Checker — Worker Pipeline","\u002Fprojects\u002Fconcurrent-url-checker\u002Fworker-pipeline","7.projects\u002F2.concurrent-url-checker\u002F1.worker-pipeline",{"title":329,"path":330,"stem":331,"icon":173},"URL Checker — Cancellation and Tests","\u002Fprojects\u002Fconcurrent-url-checker\u002Fcancellation-and-tests","7.projects\u002F2.concurrent-url-checker\u002F2.cancellation-and-tests",{"title":333,"path":334,"stem":335,"children":336},"File-backed API","\u002Fprojects\u002Ffile-backed-api","7.projects\u002F3.file-backed-api\u002Findex",[337,339,343],{"title":338,"path":334,"stem":335},"File-backed notes API",{"title":340,"path":341,"stem":342},"File store and concurrency","\u002Fprojects\u002Ffile-backed-api\u002Ffile-store-and-concurrency","7.projects\u002F3.file-backed-api\u002F1.file-store-and-concurrency",{"title":344,"path":345,"stem":346},"HTTP layer and tests","\u002Fprojects\u002Ffile-backed-api\u002Fhttp-and-tests","7.projects\u002F3.file-backed-api\u002F2.http-and-tests",{"title":348,"path":349,"stem":350,"children":351},"Production REST API","\u002Fprojects\u002Fproduction-rest-api","7.projects\u002F4.production-rest-api\u002Findex",[352,354,358],{"title":353,"path":349,"stem":350},"Production REST API capstone",{"title":355,"path":356,"stem":357},"Persistence and authentication","\u002Fprojects\u002Fproduction-rest-api\u002Fpersistence-and-auth","7.projects\u002F4.production-rest-api\u002F1.persistence-and-auth",{"title":359,"path":360,"stem":361},"Operations and release","\u002Fprojects\u002Fproduction-rest-api\u002Foperations-and-release","7.projects\u002F4.production-rest-api\u002F2.operations-and-release",{"title":363,"path":364,"stem":365,"children":366,"page":6},"Meta","\u002Fmeta","99.meta",[367,372],{"title":368,"path":369,"stem":370,"icon":371},"About","\u002Fmeta\u002Fabout","99.meta\u002F1.about","i-lucide-info",{"title":373,"path":374,"stem":375,"icon":376},"Acknowledgements","\u002Fmeta\u002Facknowledgements","99.meta\u002F2.acknowledgements","i-lucide-heart-handshake",{"id":378,"title":125,"body":379,"description":931,"extension":932,"links":933,"meta":934,"navigation":935,"path":126,"seo":936,"stem":127,"__hash__":938},"docs\u002F3.concurrency\u002F2.goroutines.md",{"type":380,"value":381,"toc":921},"minimark",[382,389,394,407,411,419,443,446,450,508,515,522,638,644,648,703,706,710,713,835,839,846,849,853,856,870,873,877,885,894,898,911,914,917],[383,384],"learning-lesson-meta",{"description":385,"difficulty":386,"prerequisites":387,"time":388},"Build clear understanding through explanation, examples, and practice.","Intermediate","Concurrency model","30 minutes",[390,391,393],"h2",{"id":392},"what-you-will-learn","What you will learn",[395,396,397,401,404],"ul",{},[398,399,400],"li",{},"start goroutines and wait for completion;",[398,402,403],{},"return errors through an explicit path;",[398,405,406],{},"prevent common goroutine leaks;",[408,409,410],"p",{},"A goroutine is a function executing concurrently with other goroutines in the same program.",[408,412,413,414,418],{},"Start one with the ",[415,416,417],"code",{},"go"," keyword:",[420,421,425],"pre",{"className":422,"code":423,"language":417,"meta":424,"style":424},"language-go shiki shiki-themes solarized-light material-theme one-dark-pro","go sendReport()\n","",[415,426,427],{"__ignoreMap":424},[428,429,432,435,439],"span",{"class":430,"line":431},"line",1,[428,433,417],{"class":434},"s7Bcg",[428,436,438],{"class":437},"sisdC"," sendReport",[428,440,442],{"class":441},"shFME","()\n",[408,444,445],{},"The call is scheduled and the current goroutine continues immediately. The runtime manages goroutines and maps them onto a smaller or equal number of operating-system threads as needed.",[390,447,449],{"id":448},"the-program-does-not-wait-automatically","The program does not wait automatically",[420,451,453],{"className":422,"code":452,"language":417,"meta":424,"style":424},"func main() {\n    go fmt.Println(\"hello from a goroutine\")\n}\n",[415,454,455,470,502],{"__ignoreMap":424},[428,456,457,461,464,467],{"class":430,"line":431},[428,458,460],{"class":459},"sEOdo","func",[428,462,463],{"class":437}," main",[428,465,466],{"class":441},"()",[428,468,469],{"class":441}," {\n",[428,471,473,476,480,483,486,489,493,497,499],{"class":430,"line":472},2,[428,474,475],{"class":434},"    go",[428,477,479],{"class":478},"s45-6"," fmt",[428,481,482],{"class":441},".",[428,484,485],{"class":437},"Println",[428,487,488],{"class":441},"(",[428,490,492],{"class":491},"sED5a","\"",[428,494,496],{"class":495},"sVazx","hello from a goroutine",[428,498,492],{"class":491},[428,500,501],{"class":441},")\n",[428,503,505],{"class":430,"line":504},3,[428,506,507],{"class":441},"}\n",[408,509,510,511,514],{},"This program may finish before the new goroutine prints anything. When ",[415,512,513],{},"main"," returns, the process ends and all remaining goroutines stop.",[408,516,517,518,521],{},"Use an explicit coordination tool rather than ",[415,519,520],{},"time.Sleep",":",[420,523,525],{"className":422,"code":524,"language":417,"meta":424,"style":424},"func main() {\n    done := make(chan struct{})\n\n    go func() {\n        fmt.Println(\"work complete\")\n        close(done)\n    }()\n\n    \u003C-done\n}\n",[415,526,527,537,560,566,578,599,612,618,623,633],{"__ignoreMap":424},[428,528,529,531,533,535],{"class":430,"line":431},[428,530,460],{"class":459},[428,532,463],{"class":437},[428,534,466],{"class":441},[428,536,469],{"class":441},[428,538,539,542,546,549,551,554,557],{"class":430,"line":472},[428,540,541],{"class":478},"    done",[428,543,545],{"class":544},"su2KV"," :=",[428,547,548],{"class":437}," make",[428,550,488],{"class":441},[428,552,553],{"class":459},"chan",[428,555,556],{"class":459}," struct",[428,558,559],{"class":441},"{})\n",[428,561,562],{"class":430,"line":504},[428,563,565],{"emptyLinePlaceholder":564},true,"\n",[428,567,569,571,574,576],{"class":430,"line":568},4,[428,570,475],{"class":434},[428,572,573],{"class":459}," func",[428,575,466],{"class":441},[428,577,469],{"class":441},[428,579,581,584,586,588,590,592,595,597],{"class":430,"line":580},5,[428,582,583],{"class":478},"        fmt",[428,585,482],{"class":441},[428,587,485],{"class":437},[428,589,488],{"class":441},[428,591,492],{"class":491},[428,593,594],{"class":495},"work complete",[428,596,492],{"class":491},[428,598,501],{"class":441},[428,600,602,605,607,610],{"class":430,"line":601},6,[428,603,604],{"class":437},"        close",[428,606,488],{"class":441},[428,608,609],{"class":478},"done",[428,611,501],{"class":441},[428,613,615],{"class":430,"line":614},7,[428,616,617],{"class":441},"    }()\n",[428,619,621],{"class":430,"line":620},8,[428,622,565],{"emptyLinePlaceholder":564},[428,624,626,630],{"class":430,"line":625},9,[428,627,629],{"class":628},"sRBoR","    \u003C-",[428,631,632],{"class":478},"done\n",[428,634,636],{"class":430,"line":635},10,[428,637,507],{"class":441},[408,639,640,641,643],{},"Receiving from ",[415,642,609],{}," blocks until it is closed.",[390,645,647],{"id":646},"anonymous-goroutines","Anonymous goroutines",[420,649,651],{"className":422,"code":650,"language":417,"meta":424,"style":424},"go func(message string) {\n    fmt.Println(message)\n}(\"processing started\")\n",[415,652,653,674,689],{"__ignoreMap":424},[428,654,655,657,659,661,665,669,672],{"class":430,"line":431},[428,656,417],{"class":434},[428,658,573],{"class":459},[428,660,488],{"class":441},[428,662,664],{"class":663},"syre3","message",[428,666,668],{"class":667},"sF6sA"," string",[428,670,671],{"class":441},")",[428,673,469],{"class":441},[428,675,676,679,681,683,685,687],{"class":430,"line":472},[428,677,678],{"class":478},"    fmt",[428,680,482],{"class":441},[428,682,485],{"class":437},[428,684,488],{"class":441},[428,686,664],{"class":478},[428,688,501],{"class":441},[428,690,691,694,696,699,701],{"class":430,"line":504},[428,692,693],{"class":441},"}(",[428,695,492],{"class":491},[428,697,698],{"class":495},"processing started",[428,700,492],{"class":491},[428,702,501],{"class":441},[408,704,705],{},"Passing values as parameters makes the data captured by the goroutine explicit.",[390,707,709],{"id":708},"errors-do-not-return-to-the-caller","Errors do not return to the caller",[408,711,712],{},"Once a function runs in another goroutine, its return values do not return to the function that started it. Send a result through a channel, store it safely, or use a coordination helper designed to collect errors.",[420,714,716],{"className":422,"code":715,"language":417,"meta":424,"style":424},"result := make(chan error, 1)\n\ngo func() {\n    result \u003C- doWork()\n}()\n\nif err := \u003C-result; err != nil {\n    log.Println(\"work failed:\", err)\n}\n",[415,717,718,743,747,757,770,775,779,807,831],{"__ignoreMap":424},[428,719,720,723,725,727,729,731,734,737,741],{"class":430,"line":431},[428,721,722],{"class":478},"result",[428,724,545],{"class":544},[428,726,548],{"class":437},[428,728,488],{"class":441},[428,730,553],{"class":459},[428,732,733],{"class":667}," error",[428,735,736],{"class":441},",",[428,738,740],{"class":739},"sAJzr"," 1",[428,742,501],{"class":441},[428,744,745],{"class":430,"line":472},[428,746,565],{"emptyLinePlaceholder":564},[428,748,749,751,753,755],{"class":430,"line":504},[428,750,417],{"class":434},[428,752,573],{"class":459},[428,754,466],{"class":441},[428,756,469],{"class":441},[428,758,759,762,765,768],{"class":430,"line":568},[428,760,761],{"class":478},"    result",[428,763,764],{"class":628}," \u003C-",[428,766,767],{"class":437}," doWork",[428,769,442],{"class":441},[428,771,772],{"class":430,"line":580},[428,773,774],{"class":441},"}()\n",[428,776,777],{"class":430,"line":601},[428,778,565],{"emptyLinePlaceholder":564},[428,780,781,784,787,789,791,793,796,798,801,805],{"class":430,"line":614},[428,782,783],{"class":434},"if",[428,785,786],{"class":478}," err",[428,788,545],{"class":544},[428,790,764],{"class":628},[428,792,722],{"class":478},[428,794,795],{"class":441},";",[428,797,786],{"class":478},[428,799,800],{"class":628}," !=",[428,802,804],{"class":803},"sp8Z5"," nil",[428,806,469],{"class":441},[428,808,809,812,814,816,818,820,823,825,827,829],{"class":430,"line":620},[428,810,811],{"class":478},"    log",[428,813,482],{"class":441},[428,815,485],{"class":437},[428,817,488],{"class":441},[428,819,492],{"class":491},[428,821,822],{"class":495},"work failed:",[428,824,492],{"class":491},[428,826,736],{"class":441},[428,828,786],{"class":478},[428,830,501],{"class":441},[428,832,833],{"class":430,"line":625},[428,834,507],{"class":441},[390,836,838],{"id":837},"panics-stay-in-the-process","Panics stay in the process",[408,840,841,842,845],{},"An unrecovered panic in any goroutine normally crashes the whole program. A ",[415,843,844],{},"recover"," call only catches a panic in the same goroutine, and only when called from a deferred function.",[408,847,848],{},"Do not use recovery as routine error handling. Prefer returning errors through a defined result path.",[390,850,852],{"id":851},"goroutine-leaks","Goroutine leaks",[408,854,855],{},"A goroutine leaks when it remains blocked or running after nobody needs its result. Common causes include:",[395,857,858,861,864,867],{},[398,859,860],{},"sending to a channel with no receiver;",[398,862,863],{},"waiting on a channel that is never closed;",[398,865,866],{},"retrying forever without cancellation;",[398,868,869],{},"starting background work per request without a stop path.",[408,871,872],{},"Leaked goroutines retain their stacks and references, so they can become a production memory problem.",[390,874,876],{"id":875},"practice","Practice",[408,878,879,880,882,883,482],{},"Run three functions concurrently. Each should send a message to a channel when complete. Make ",[415,881,513],{}," wait for all three messages without using ",[415,884,520],{},[886,887,888],"accordion",{},[889,890,893],"accordion-item",{"icon":891,"label":892},"i-lucide-lightbulb","Show solution","Start a bounded number of goroutines, arrange waiting before returning, and send results on a channel that a known owner closes after all senders finish. Pass a context when work may need cancellation.",[390,895,897],{"id":896},"summary","Summary",[395,899,900,905,908],{},[398,901,902,904],{},[415,903,417],{}," starts concurrent execution but does not make the caller wait.",[398,906,907],{},"Goroutine errors need an explicit communication path.",[398,909,910],{},"Blocked sends, receives, or missing cancellation commonly leak goroutines.",[912,913],"learning-lesson-complete",{},[915,916],"learning-lesson-navigation",{"next":131,"nextTitle":130,"previous":121,"previousTitle":387},[918,919,920],"style",{},"html pre.shiki code .s7Bcg, html code.shiki .s7Bcg{--shiki-light:#859900;--shiki-light-font-style:inherit;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#C678DD;--shiki-dark-font-style:inherit}html pre.shiki code .sisdC, html code.shiki .sisdC{--shiki-light:#268BD2;--shiki-default:#82AAFF;--shiki-dark:#61AFEF}html pre.shiki code .shFME, html code.shiki .shFME{--shiki-light:#657B83;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sEOdo, html code.shiki .sEOdo{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#C678DD}html pre.shiki code .s45-6, html code.shiki .s45-6{--shiki-light:#268BD2;--shiki-default:#EEFFFF;--shiki-dark:#E06C75}html pre.shiki code .sED5a, html code.shiki .sED5a{--shiki-light:#2AA198;--shiki-default:#89DDFF;--shiki-dark:#98C379}html pre.shiki code .sVazx, html code.shiki .sVazx{--shiki-light:#2AA198;--shiki-default:#C3E88D;--shiki-dark:#98C379}html pre.shiki code .su2KV, html code.shiki .su2KV{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#E5C07B}html pre.shiki code .sRBoR, html code.shiki .sRBoR{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#56B6C2}html pre.shiki code .syre3, html code.shiki .syre3{--shiki-light:#657B83;--shiki-light-font-style:inherit;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#E06C75;--shiki-dark-font-style:italic}html pre.shiki code .sF6sA, html code.shiki .sF6sA{--shiki-light:#586E75;--shiki-light-font-weight:bold;--shiki-default:#C792EA;--shiki-default-font-weight:inherit;--shiki-dark:#C678DD;--shiki-dark-font-weight:inherit}html pre.shiki code .sAJzr, html code.shiki .sAJzr{--shiki-light:#D33682;--shiki-default:#F78C6C;--shiki-dark:#D19A66}html pre.shiki code .sp8Z5, html code.shiki .sp8Z5{--shiki-light:#B58900;--shiki-default:#89DDFF;--shiki-dark:#D19A66}",{"title":424,"searchDepth":472,"depth":472,"links":922},[923,924,925,926,927,928,929,930],{"id":392,"depth":472,"text":393},{"id":448,"depth":472,"text":449},{"id":646,"depth":472,"text":647},{"id":708,"depth":472,"text":709},{"id":837,"depth":472,"text":838},{"id":851,"depth":472,"text":852},{"id":875,"depth":472,"text":876},{"id":896,"depth":472,"text":897},"Start lightweight concurrent functions and manage their lifetime correctly.","md",null,{},{"icon":128},{"description":937,"title":125},"Learn how Go goroutines start, run, capture variables, fail, and finish.","TPnLYzwSNDjwCiaPOfeJXXLFJAgTeoa6uVTkhQi5E98",[940,942],{"title":120,"path":121,"stem":122,"description":941,"icon":123,"children":-1},"Understand concurrency, parallelism, goroutines, coordination, and ownership before writing concurrent code.",{"title":130,"path":131,"stem":132,"description":943,"icon":133,"children":-1},"Send values between goroutines and understand blocking, buffering, closing, and ownership.",1794118095652]