[{"data":1,"prerenderedAt":1344},["ShallowReactive",2],{"navigation_docs":3,"-standard-library-files-and-json":377,"-standard-library-files-and-json-surround":1339},[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":160,"body":379,"description":1331,"extension":1332,"links":1333,"meta":1334,"navigation":1335,"path":161,"seo":1336,"stem":162,"__hash__":1338},"docs\u002F4.standard-library\u002F3.files-and-json.md",{"type":380,"value":381,"toc":1320},"minimark",[382,389,394,407,411,415,561,567,571,776,787,791,904,910,913,917,920,1088,1091,1095,1178,1181,1191,1259,1266,1270,1273,1277,1284,1293,1297,1308,1311,1316],[383,384],"learning-lesson-meta",{"description":385,"difficulty":386,"prerequisites":387,"time":388},"Read, write, stream, encode, and decode data while preserving ownership and errors.","Intermediate","Text, structs, slices, and errors","40 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",{},"choose whole-file or streaming I\u002FO;",[398,402,403],{},"encode and decode JSON with explicit structs;",[398,405,406],{},"close resources and preserve useful errors;",[408,409,410],"p",{},"Files provide bytes. JSON turns Go values into a portable text format. The standard library makes both tasks straightforward, but resource ownership and errors still matter.",[390,412,414],{"id":413},"read-a-small-file","Read a small file",[416,417,422],"pre",{"className":418,"code":419,"language":420,"meta":421,"style":421},"language-go shiki shiki-themes solarized-light material-theme one-dark-pro","data, err := os.ReadFile(\"config.json\")\nif err != nil {\n    return fmt.Errorf(\"read config: %w\", err)\n}\n\nfmt.Println(string(data))\n","go","",[423,424,425,471,491,524,530,537],"code",{"__ignoreMap":421},[426,427,430,434,438,441,445,448,451,455,458,462,466,468],"span",{"class":428,"line":429},"line",1,[426,431,433],{"class":432},"s45-6","data",[426,435,437],{"class":436},"shFME",",",[426,439,440],{"class":432}," err",[426,442,444],{"class":443},"su2KV"," :=",[426,446,447],{"class":432}," os",[426,449,450],{"class":436},".",[426,452,454],{"class":453},"sisdC","ReadFile",[426,456,457],{"class":436},"(",[426,459,461],{"class":460},"sED5a","\"",[426,463,465],{"class":464},"sVazx","config.json",[426,467,461],{"class":460},[426,469,470],{"class":436},")\n",[426,472,474,478,480,484,488],{"class":428,"line":473},2,[426,475,477],{"class":476},"s7Bcg","if",[426,479,440],{"class":432},[426,481,483],{"class":482},"sRBoR"," !=",[426,485,487],{"class":486},"sp8Z5"," nil",[426,489,490],{"class":436}," {\n",[426,492,494,497,500,502,505,507,509,512,516,518,520,522],{"class":428,"line":493},3,[426,495,496],{"class":476},"    return",[426,498,499],{"class":432}," fmt",[426,501,450],{"class":436},[426,503,504],{"class":453},"Errorf",[426,506,457],{"class":436},[426,508,461],{"class":460},[426,510,511],{"class":464},"read config: ",[426,513,515],{"class":514},"st3jj","%w",[426,517,461],{"class":460},[426,519,437],{"class":436},[426,521,440],{"class":432},[426,523,470],{"class":436},[426,525,527],{"class":428,"line":526},4,[426,528,529],{"class":436},"}\n",[426,531,533],{"class":428,"line":532},5,[426,534,536],{"emptyLinePlaceholder":535},true,"\n",[426,538,540,543,545,548,550,554,556,558],{"class":428,"line":539},6,[426,541,542],{"class":432},"fmt",[426,544,450],{"class":436},[426,546,547],{"class":453},"Println",[426,549,457],{"class":436},[426,551,553],{"class":552},"sF6sA","string",[426,555,457],{"class":436},[426,557,433],{"class":432},[426,559,560],{"class":436},"))\n",[408,562,563,566],{},[423,564,565],{},"os.ReadFile"," loads the entire file into memory. It is convenient for configuration and other reasonably small files.",[390,568,570],{"id":569},"stream-a-large-file","Stream a large file",[416,572,574],{"className":418,"code":573,"language":420,"meta":421,"style":421},"file, err := os.Open(\"events.log\")\nif err != nil {\n    return err\n}\ndefer file.Close()\n\nscanner := bufio.NewScanner(file)\nfor scanner.Scan() {\n    fmt.Println(scanner.Text())\n}\nif err := scanner.Err(); err != nil {\n    return fmt.Errorf(\"scan events: %w\", err)\n}\n",[423,575,576,605,617,624,628,644,648,670,689,711,716,743,771],{"__ignoreMap":421},[426,577,578,581,583,585,587,589,591,594,596,598,601,603],{"class":428,"line":429},[426,579,580],{"class":432},"file",[426,582,437],{"class":436},[426,584,440],{"class":432},[426,586,444],{"class":443},[426,588,447],{"class":432},[426,590,450],{"class":436},[426,592,593],{"class":453},"Open",[426,595,457],{"class":436},[426,597,461],{"class":460},[426,599,600],{"class":464},"events.log",[426,602,461],{"class":460},[426,604,470],{"class":436},[426,606,607,609,611,613,615],{"class":428,"line":473},[426,608,477],{"class":476},[426,610,440],{"class":432},[426,612,483],{"class":482},[426,614,487],{"class":486},[426,616,490],{"class":436},[426,618,619,621],{"class":428,"line":493},[426,620,496],{"class":476},[426,622,623],{"class":432}," err\n",[426,625,626],{"class":428,"line":526},[426,627,529],{"class":436},[426,629,630,633,636,638,641],{"class":428,"line":532},[426,631,632],{"class":476},"defer",[426,634,635],{"class":432}," file",[426,637,450],{"class":436},[426,639,640],{"class":453},"Close",[426,642,643],{"class":436},"()\n",[426,645,646],{"class":428,"line":539},[426,647,536],{"emptyLinePlaceholder":535},[426,649,651,654,656,659,661,664,666,668],{"class":428,"line":650},7,[426,652,653],{"class":432},"scanner",[426,655,444],{"class":443},[426,657,658],{"class":432}," bufio",[426,660,450],{"class":436},[426,662,663],{"class":453},"NewScanner",[426,665,457],{"class":436},[426,667,580],{"class":432},[426,669,470],{"class":436},[426,671,673,676,679,681,684,687],{"class":428,"line":672},8,[426,674,675],{"class":476},"for",[426,677,678],{"class":432}," scanner",[426,680,450],{"class":436},[426,682,683],{"class":453},"Scan",[426,685,686],{"class":436},"()",[426,688,490],{"class":436},[426,690,692,695,697,699,701,703,705,708],{"class":428,"line":691},9,[426,693,694],{"class":432},"    fmt",[426,696,450],{"class":436},[426,698,547],{"class":453},[426,700,457],{"class":436},[426,702,653],{"class":432},[426,704,450],{"class":436},[426,706,707],{"class":453},"Text",[426,709,710],{"class":436},"())\n",[426,712,714],{"class":428,"line":713},10,[426,715,529],{"class":436},[426,717,719,721,723,725,727,729,732,735,737,739,741],{"class":428,"line":718},11,[426,720,477],{"class":476},[426,722,440],{"class":432},[426,724,444],{"class":443},[426,726,678],{"class":432},[426,728,450],{"class":436},[426,730,731],{"class":453},"Err",[426,733,734],{"class":436},"();",[426,736,440],{"class":432},[426,738,483],{"class":482},[426,740,487],{"class":486},[426,742,490],{"class":436},[426,744,746,748,750,752,754,756,758,761,763,765,767,769],{"class":428,"line":745},12,[426,747,496],{"class":476},[426,749,499],{"class":432},[426,751,450],{"class":436},[426,753,504],{"class":453},[426,755,457],{"class":436},[426,757,461],{"class":460},[426,759,760],{"class":464},"scan events: ",[426,762,515],{"class":514},[426,764,461],{"class":460},[426,766,437],{"class":436},[426,768,440],{"class":432},[426,770,470],{"class":436},[426,772,774],{"class":428,"line":773},13,[426,775,529],{"class":436},[408,777,778,779,782,783,786],{},"Always check ",[423,780,781],{},"scanner.Err()"," after the loop. The default scanner has a token-size limit; increase its buffer or use ",[423,784,785],{},"bufio.Reader"," when lines may be very large.",[390,788,790],{"id":789},"write-a-file","Write a file",[416,792,794],{"className":418,"code":793,"language":420,"meta":421,"style":421},"data := []byte(\"learning Go\\n\")\nif err := os.WriteFile(\"progress.txt\", data, 0o644); err != nil {\n    return fmt.Errorf(\"write progress: %w\", err)\n}\n",[423,795,796,823,873,900],{"__ignoreMap":421},[426,797,798,800,802,805,808,810,812,815,819,821],{"class":428,"line":429},[426,799,433],{"class":432},[426,801,444],{"class":443},[426,803,804],{"class":436}," []",[426,806,807],{"class":552},"byte",[426,809,457],{"class":436},[426,811,461],{"class":460},[426,813,814],{"class":464},"learning Go",[426,816,818],{"class":817},"sk51v","\\n",[426,820,461],{"class":460},[426,822,470],{"class":436},[426,824,825,827,829,831,833,835,838,840,842,845,847,849,852,854,858,862,865,867,869,871],{"class":428,"line":473},[426,826,477],{"class":476},[426,828,440],{"class":432},[426,830,444],{"class":443},[426,832,447],{"class":432},[426,834,450],{"class":436},[426,836,837],{"class":453},"WriteFile",[426,839,457],{"class":436},[426,841,461],{"class":460},[426,843,844],{"class":464},"progress.txt",[426,846,461],{"class":460},[426,848,437],{"class":436},[426,850,851],{"class":432}," data",[426,853,437],{"class":436},[426,855,857],{"class":856},"skh9b"," 0o",[426,859,861],{"class":860},"sAJzr","644",[426,863,864],{"class":436},");",[426,866,440],{"class":432},[426,868,483],{"class":482},[426,870,487],{"class":486},[426,872,490],{"class":436},[426,874,875,877,879,881,883,885,887,890,892,894,896,898],{"class":428,"line":493},[426,876,496],{"class":476},[426,878,499],{"class":432},[426,880,450],{"class":436},[426,882,504],{"class":453},[426,884,457],{"class":436},[426,886,461],{"class":460},[426,888,889],{"class":464},"write progress: ",[426,891,515],{"class":514},[426,893,461],{"class":460},[426,895,437],{"class":436},[426,897,440],{"class":432},[426,899,470],{"class":436},[426,901,902],{"class":428,"line":526},[426,903,529],{"class":436},[408,905,906,909],{},[423,907,908],{},"0o644"," is the requested Unix permission mode. Windows handles permissions differently.",[408,911,912],{},"For sensitive or critical data, consider restrictive permissions and an atomic-write strategy rather than replacing the destination directly.",[390,914,916],{"id":915},"encode-json","Encode JSON",[408,918,919],{},"Only exported struct fields are encoded.",[416,921,923],{"className":418,"code":922,"language":420,"meta":421,"style":421},"type Lesson struct {\n    Title     string `json:\"title\"`\n    Completed bool   `json:\"completed\"`\n}\n\nlesson := Lesson{Title: \"Slices\", Completed: true}\ndata, err := json.Marshal(lesson)\nif err != nil {\n    return err\n}\n\nfmt.Println(string(data))\n",[423,924,925,940,957,973,977,981,1020,1044,1056,1062,1066,1070],{"__ignoreMap":421},[426,926,927,931,935,938],{"class":428,"line":429},[426,928,930],{"class":929},"sEOdo","type",[426,932,934],{"class":933},"snwKR"," Lesson",[426,936,937],{"class":929}," struct",[426,939,490],{"class":436},[426,941,942,945,948,951,954],{"class":428,"line":473},[426,943,944],{"class":432},"    Title",[426,946,947],{"class":552},"     string",[426,949,950],{"class":460}," `",[426,952,953],{"class":464},"json:\"title\"",[426,955,956],{"class":460},"`\n",[426,958,959,962,965,968,971],{"class":428,"line":493},[426,960,961],{"class":432},"    Completed",[426,963,964],{"class":552}," bool",[426,966,967],{"class":460},"   `",[426,969,970],{"class":464},"json:\"completed\"",[426,972,956],{"class":460},[426,974,975],{"class":428,"line":526},[426,976,529],{"class":436},[426,978,979],{"class":428,"line":532},[426,980,536],{"emptyLinePlaceholder":535},[426,982,983,986,988,990,993,996,999,1002,1005,1007,1009,1012,1014,1018],{"class":428,"line":539},[426,984,985],{"class":432},"lesson",[426,987,444],{"class":443},[426,989,934],{"class":933},[426,991,992],{"class":436},"{",[426,994,995],{"class":432},"Title",[426,997,998],{"class":436},":",[426,1000,1001],{"class":460}," \"",[426,1003,1004],{"class":464},"Slices",[426,1006,461],{"class":460},[426,1008,437],{"class":436},[426,1010,1011],{"class":432}," Completed",[426,1013,998],{"class":436},[426,1015,1017],{"class":1016},"sqQ1y"," true",[426,1019,529],{"class":436},[426,1021,1022,1024,1026,1028,1030,1033,1035,1038,1040,1042],{"class":428,"line":650},[426,1023,433],{"class":432},[426,1025,437],{"class":436},[426,1027,440],{"class":432},[426,1029,444],{"class":443},[426,1031,1032],{"class":432}," json",[426,1034,450],{"class":436},[426,1036,1037],{"class":453},"Marshal",[426,1039,457],{"class":436},[426,1041,985],{"class":432},[426,1043,470],{"class":436},[426,1045,1046,1048,1050,1052,1054],{"class":428,"line":672},[426,1047,477],{"class":476},[426,1049,440],{"class":432},[426,1051,483],{"class":482},[426,1053,487],{"class":486},[426,1055,490],{"class":436},[426,1057,1058,1060],{"class":428,"line":691},[426,1059,496],{"class":476},[426,1061,623],{"class":432},[426,1063,1064],{"class":428,"line":713},[426,1065,529],{"class":436},[426,1067,1068],{"class":428,"line":718},[426,1069,536],{"emptyLinePlaceholder":535},[426,1071,1072,1074,1076,1078,1080,1082,1084,1086],{"class":428,"line":745},[426,1073,542],{"class":432},[426,1075,450],{"class":436},[426,1077,547],{"class":453},[426,1079,457],{"class":436},[426,1081,553],{"class":552},[426,1083,457],{"class":436},[426,1085,433],{"class":432},[426,1087,560],{"class":436},[408,1089,1090],{},"Struct tags control JSON field names.",[390,1092,1094],{"id":1093},"decode-json","Decode JSON",[416,1096,1098],{"className":418,"code":1097,"language":420,"meta":421,"style":421},"var lesson Lesson\nif err := json.Unmarshal(data, &lesson); err != nil {\n    return fmt.Errorf(\"decode lesson: %w\", err)\n}\n",[423,1099,1100,1111,1147,1174],{"__ignoreMap":421},[426,1101,1102,1105,1108],{"class":428,"line":429},[426,1103,1104],{"class":929},"var",[426,1106,1107],{"class":432}," lesson",[426,1109,1110],{"class":933}," Lesson\n",[426,1112,1113,1115,1117,1119,1121,1123,1126,1128,1130,1132,1135,1137,1139,1141,1143,1145],{"class":428,"line":473},[426,1114,477],{"class":476},[426,1116,440],{"class":432},[426,1118,444],{"class":443},[426,1120,1032],{"class":432},[426,1122,450],{"class":436},[426,1124,1125],{"class":453},"Unmarshal",[426,1127,457],{"class":436},[426,1129,433],{"class":432},[426,1131,437],{"class":436},[426,1133,1134],{"class":929}," &",[426,1136,985],{"class":432},[426,1138,864],{"class":436},[426,1140,440],{"class":432},[426,1142,483],{"class":482},[426,1144,487],{"class":486},[426,1146,490],{"class":436},[426,1148,1149,1151,1153,1155,1157,1159,1161,1164,1166,1168,1170,1172],{"class":428,"line":493},[426,1150,496],{"class":476},[426,1152,499],{"class":432},[426,1154,450],{"class":436},[426,1156,504],{"class":453},[426,1158,457],{"class":436},[426,1160,461],{"class":460},[426,1162,1163],{"class":464},"decode lesson: ",[426,1165,515],{"class":514},[426,1167,461],{"class":460},[426,1169,437],{"class":436},[426,1171,440],{"class":432},[426,1173,470],{"class":436},[426,1175,1176],{"class":428,"line":526},[426,1177,529],{"class":436},[408,1179,1180],{},"Pass a pointer so the decoder can fill the value.",[408,1182,1183,1184,1187,1188,998],{},"For streams, use ",[423,1185,1186],{},"json.Decoder"," and ",[423,1189,1190],{},"json.Encoder",[416,1192,1194],{"className":418,"code":1193,"language":420,"meta":421,"style":421},"decoder := json.NewDecoder(file)\nif err := decoder.Decode(&lesson); err != nil {\n    return err\n}\n",[423,1195,1196,1216,1249,1255],{"__ignoreMap":421},[426,1197,1198,1201,1203,1205,1207,1210,1212,1214],{"class":428,"line":429},[426,1199,1200],{"class":432},"decoder",[426,1202,444],{"class":443},[426,1204,1032],{"class":432},[426,1206,450],{"class":436},[426,1208,1209],{"class":453},"NewDecoder",[426,1211,457],{"class":436},[426,1213,580],{"class":432},[426,1215,470],{"class":436},[426,1217,1218,1220,1222,1224,1227,1229,1232,1234,1237,1239,1241,1243,1245,1247],{"class":428,"line":473},[426,1219,477],{"class":476},[426,1221,440],{"class":432},[426,1223,444],{"class":443},[426,1225,1226],{"class":432}," decoder",[426,1228,450],{"class":436},[426,1230,1231],{"class":453},"Decode",[426,1233,457],{"class":436},[426,1235,1236],{"class":929},"&",[426,1238,985],{"class":432},[426,1240,864],{"class":436},[426,1242,440],{"class":432},[426,1244,483],{"class":482},[426,1246,487],{"class":486},[426,1248,490],{"class":436},[426,1250,1251,1253],{"class":428,"line":493},[426,1252,496],{"class":476},[426,1254,623],{"class":432},[426,1256,1257],{"class":428,"line":526},[426,1258,529],{"class":436},[408,1260,1261,1262,1265],{},"When decoding untrusted API input, you may call ",[423,1263,1264],{},"DisallowUnknownFields"," to reject fields your struct does not recognise.",[390,1267,1269],{"id":1268},"missing-and-zero-values","Missing and zero values",[408,1271,1272],{},"When a JSON field is missing, the Go field keeps its zero value. If an API must distinguish “missing” from “present with zero,” use a pointer, a custom type, or dedicated validation logic.",[390,1274,1276],{"id":1275},"practice","Practice",[408,1278,1279,1280,1283],{},"Create a slice of lessons, encode it to ",[423,1281,1282],{},"progress.json",", read it back, and print only incomplete lessons. Add useful context to every returned error.",[1285,1286,1287],"accordion",{},[1288,1289,1292],"accordion-item",{"icon":1290,"label":1291},"i-lucide-lightbulb","Show solution","Open the file, check the error, and defer closure. Decode into a struct with JSON tags, decide whether unknown fields are allowed, and distinguish missing values if the API needs to. Wrap errors with the operation and path, without leaking sensitive paths to remote clients.",[390,1294,1296],{"id":1295},"summary","Summary",[395,1298,1299,1302,1305],{},[398,1300,1301],{},"Whole-file helpers suit bounded small inputs; streams suit large or ongoing data.",[398,1303,1304],{},"The code that opens a resource normally owns closing it.",[398,1306,1307],{},"JSON zero values cannot always distinguish missing from explicitly zero.",[1309,1310],"learning-lesson-complete",{},[1312,1313],"learning-lesson-navigation",{"next":166,"nextTitle":1314,"previous":156,"previousTitle":1315},"HTTP clients and servers","Text and formatting",[1317,1318,1319],"style",{},"html pre.shiki code .s45-6, html code.shiki .s45-6{--shiki-light:#268BD2;--shiki-default:#EEFFFF;--shiki-dark:#E06C75}html pre.shiki code .shFME, html code.shiki .shFME{--shiki-light:#657B83;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}html pre.shiki code .su2KV, html code.shiki .su2KV{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#E5C07B}html pre.shiki code .sisdC, html code.shiki .sisdC{--shiki-light:#268BD2;--shiki-default:#82AAFF;--shiki-dark:#61AFEF}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 .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 .sRBoR, html code.shiki .sRBoR{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#56B6C2}html pre.shiki code .sp8Z5, html code.shiki .sp8Z5{--shiki-light:#B58900;--shiki-default:#89DDFF;--shiki-dark:#D19A66}html pre.shiki code .st3jj, html code.shiki .st3jj{--shiki-light:#CB4B16;--shiki-default:#F07178;--shiki-dark:#D19A66}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 .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 .sk51v, html code.shiki .sk51v{--shiki-light:#CB4B16;--shiki-default:#EEFFFF;--shiki-dark:#56B6C2}html pre.shiki code .skh9b, html code.shiki .skh9b{--shiki-light:#859900;--shiki-default:#F78C6C;--shiki-dark:#E06C75}html pre.shiki code .sAJzr, html code.shiki .sAJzr{--shiki-light:#D33682;--shiki-default:#F78C6C;--shiki-dark:#D19A66}html pre.shiki code .sEOdo, html code.shiki .sEOdo{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#C678DD}html pre.shiki code .snwKR, html code.shiki .snwKR{--shiki-light:#CB4B16;--shiki-default:#FFCB6B;--shiki-dark:#E5C07B}html pre.shiki code .sqQ1y, html code.shiki .sqQ1y{--shiki-light:#B58900;--shiki-default:#FF9CAC;--shiki-dark:#D19A66}",{"title":421,"searchDepth":473,"depth":473,"links":1321},[1322,1323,1324,1325,1326,1327,1328,1329,1330],{"id":392,"depth":473,"text":393},{"id":413,"depth":473,"text":414},{"id":569,"depth":473,"text":570},{"id":789,"depth":473,"text":790},{"id":915,"depth":473,"text":916},{"id":1093,"depth":473,"text":1094},{"id":1268,"depth":473,"text":1269},{"id":1275,"depth":473,"text":1276},{"id":1295,"depth":473,"text":1296},"Read and write files, stream data, and encode structured values as JSON.","md",null,{},{"icon":163},{"description":1337,"title":160},"Learn os, io, bufio, and encoding\u002Fjson through safe file and JSON examples in Go.","JE3LvvN5wz9TK6e5DuhDE_26CmTyKR-0h9HWl2KQSdI",[1340,1342],{"title":155,"path":156,"stem":157,"description":1341,"icon":158,"children":-1},"Format output, manipulate strings, convert values, and handle Unicode correctly.",{"title":165,"path":166,"stem":167,"description":1343,"icon":168,"children":-1},"Build a small HTTP server and call external services safely with net\u002Fhttp.",1794118100294]