[{"data":1,"prerenderedAt":2244},["ShallowReactive",2],{"navigation_docs":3,"-advanced-go-reflection":377,"-advanced-go-reflection-surround":2239},[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":255,"body":379,"description":2231,"extension":2232,"links":2233,"meta":2234,"navigation":2235,"path":256,"seo":2236,"stem":257,"__hash__":2238},"docs\u002F6.advanced-go\u002F2.reflection.md",{"type":380,"value":381,"toc":2216},"minimark",[382,388,393,397,421,425,428,431,441,593,612,615,705,709,722,732,735,739,1001,1010,1014,1112,1119,1123,1129,1197,1200,1332,1335,1339,1342,1375,1378,1381,1385,1391,1397,1401,1437,1441,1448,2169,2173,2193,2206,2209,2212],[383,384],"learning-lesson-meta",{"level":385,"prerequisites":386,"time":387},"Advanced","Interfaces, defined types, pointers, structs, methods, and generics","60–75 minutes",[389,390,392],"h2",{"id":391},"what-you-will-learn","What you will learn",[394,395,396],"p",{},"By the end of this lesson, you will be able to:",[398,399,400,404,412,415,418],"ul",{},[401,402,403],"li",{},"inspect dynamic type and value information;",[401,405,406,407,411],{},"distinguish a concrete type from its ",[408,409,410],"code",{},"Kind",";",[401,413,414],{},"understand validity, addressability, and settability;",[401,416,417],{},"read struct tags deliberately;",[401,419,420],{},"contain reflective code behind a typed API and decide when not to use it.",[389,422,424],{"id":423},"mental-model-runtime-type-inspection","Mental model: runtime type inspection",[394,426,427],{},"Ordinary Go code uses compile-time types. Reflection lets code inspect and sometimes manipulate type information at runtime.",[394,429,430],{},"It powers features such as encoders, dependency tools, test utilities, and generic data mappers. It also moves many mistakes from compile time to runtime.",[389,432,434,437,438],{"id":433},"type-and-value",[408,435,436],{},"Type"," and ",[408,439,440],{},"Value",[442,443,448],"pre",{"className":444,"code":445,"language":446,"meta":447,"style":447},"language-go shiki shiki-themes solarized-light material-theme one-dark-pro","input := 42\nvalue := reflect.ValueOf(input)\ntyp := reflect.TypeOf(input)\n\nfmt.Println(typ.Name())  \u002F\u002F int\nfmt.Println(typ.Kind())  \u002F\u002F int\nfmt.Println(value.Int()) \u002F\u002F 42\n","go","",[408,449,450,467,494,515,522,549,570],{"__ignoreMap":447},[451,452,455,459,463],"span",{"class":453,"line":454},"line",1,[451,456,458],{"class":457},"s45-6","input",[451,460,462],{"class":461},"su2KV"," :=",[451,464,466],{"class":465},"sAJzr"," 42\n",[451,468,470,473,475,478,482,486,489,491],{"class":453,"line":469},2,[451,471,472],{"class":457},"value",[451,474,462],{"class":461},[451,476,477],{"class":457}," reflect",[451,479,481],{"class":480},"shFME",".",[451,483,485],{"class":484},"sisdC","ValueOf",[451,487,488],{"class":480},"(",[451,490,458],{"class":457},[451,492,493],{"class":480},")\n",[451,495,497,500,502,504,506,509,511,513],{"class":453,"line":496},3,[451,498,499],{"class":457},"typ",[451,501,462],{"class":461},[451,503,477],{"class":457},[451,505,481],{"class":480},[451,507,508],{"class":484},"TypeOf",[451,510,488],{"class":480},[451,512,458],{"class":457},[451,514,493],{"class":480},[451,516,518],{"class":453,"line":517},4,[451,519,521],{"emptyLinePlaceholder":520},true,"\n",[451,523,525,528,530,533,535,537,539,542,545],{"class":453,"line":524},5,[451,526,527],{"class":457},"fmt",[451,529,481],{"class":480},[451,531,532],{"class":484},"Println",[451,534,488],{"class":480},[451,536,499],{"class":457},[451,538,481],{"class":480},[451,540,541],{"class":484},"Name",[451,543,544],{"class":480},"())",[451,546,548],{"class":547},"sJsHy","  \u002F\u002F int\n",[451,550,552,554,556,558,560,562,564,566,568],{"class":453,"line":551},6,[451,553,527],{"class":457},[451,555,481],{"class":480},[451,557,532],{"class":484},[451,559,488],{"class":480},[451,561,499],{"class":457},[451,563,481],{"class":480},[451,565,410],{"class":484},[451,567,544],{"class":480},[451,569,548],{"class":547},[451,571,573,575,577,579,581,583,585,588,590],{"class":453,"line":572},7,[451,574,527],{"class":457},[451,576,481],{"class":480},[451,578,532],{"class":484},[451,580,488],{"class":480},[451,582,472],{"class":457},[451,584,481],{"class":480},[451,586,587],{"class":484},"Int",[451,589,544],{"class":480},[451,591,592],{"class":547}," \u002F\u002F 42\n",[398,594,595,601,607],{},[401,596,597,600],{},[408,598,599],{},"reflect.Type"," describes a Go type.",[401,602,603,606],{},[408,604,605],{},"reflect.Value"," represents a runtime value.",[401,608,609,611],{},[408,610,410],{}," is the broad representation category such as struct, slice, pointer, or string.",[394,613,614],{},"Defined types can have the same kind but different identities:",[442,616,618],{"className":444,"code":617,"language":446,"meta":447,"style":447},"type UserID int64\n\ntyp := reflect.TypeOf(UserID(42))\nfmt.Println(typ.Name()) \u002F\u002F UserID\nfmt.Println(typ.Kind()) \u002F\u002F int64\n",[408,619,620,634,638,663,684],{"__ignoreMap":447},[451,621,622,626,630],{"class":453,"line":454},[451,623,625],{"class":624},"sEOdo","type",[451,627,629],{"class":628},"snwKR"," UserID",[451,631,633],{"class":632},"sF6sA"," int64\n",[451,635,636],{"class":453,"line":469},[451,637,521],{"emptyLinePlaceholder":520},[451,639,640,642,644,646,648,650,652,655,657,660],{"class":453,"line":496},[451,641,499],{"class":457},[451,643,462],{"class":461},[451,645,477],{"class":457},[451,647,481],{"class":480},[451,649,508],{"class":484},[451,651,488],{"class":480},[451,653,654],{"class":484},"UserID",[451,656,488],{"class":480},[451,658,659],{"class":465},"42",[451,661,662],{"class":480},"))\n",[451,664,665,667,669,671,673,675,677,679,681],{"class":453,"line":517},[451,666,527],{"class":457},[451,668,481],{"class":480},[451,670,532],{"class":484},[451,672,488],{"class":480},[451,674,499],{"class":457},[451,676,481],{"class":480},[451,678,541],{"class":484},[451,680,544],{"class":480},[451,682,683],{"class":547}," \u002F\u002F UserID\n",[451,685,686,688,690,692,694,696,698,700,702],{"class":453,"line":524},[451,687,527],{"class":457},[451,689,481],{"class":480},[451,691,532],{"class":484},[451,693,488],{"class":480},[451,695,499],{"class":457},[451,697,481],{"class":480},[451,699,410],{"class":484},[451,701,544],{"class":480},[451,703,704],{"class":547}," \u002F\u002F int64\n",[389,706,708],{"id":707},"invalid-and-nil-values","Invalid and nil values",[394,710,711,714,715,717,718,721],{},[408,712,713],{},"reflect.ValueOf(nil)"," returns an invalid ",[408,716,440],{},". Check ",[408,719,720],{},"IsValid"," before most other operations.",[394,723,724,725,728,729,731],{},"For values whose kind can be nil—such as pointers, maps, slices, channels, functions, and interfaces—",[408,726,727],{},"IsNil"," reports whether the represented value is nil. Calling ",[408,730,727],{}," on an unsupported kind panics.",[394,733,734],{},"Reflection APIs often panic when used with the wrong kind. Check preconditions and turn panics into ordinary validation errors at your boundary rather than letting arbitrary caller input reach unsafe operations.",[389,736,738],{"id":737},"read-a-struct","Read a struct",[442,740,742],{"className":444,"code":741,"language":446,"meta":447,"style":447},"type Lesson struct {\n    Title     string `json:\"title\"`\n    Published bool   `json:\"published\"`\n}\n\nlesson := Lesson{Title: \"Reflection\", Published: true}\nvalue := reflect.ValueOf(lesson)\ntyp := value.Type()\n\nfor index := 0; index \u003C value.NumField(); index++ {\n    fieldType := typ.Field(index)\n    fieldValue := value.Field(index)\n    fmt.Println(fieldType.Name, fieldValue.Interface())\n}\n",[408,743,744,757,776,792,797,801,841,859,876,881,921,944,964,996],{"__ignoreMap":447},[451,745,746,748,751,754],{"class":453,"line":454},[451,747,625],{"class":624},[451,749,750],{"class":628}," Lesson",[451,752,753],{"class":624}," struct",[451,755,756],{"class":480}," {\n",[451,758,759,762,765,769,773],{"class":453,"line":469},[451,760,761],{"class":457},"    Title",[451,763,764],{"class":632},"     string",[451,766,768],{"class":767},"sED5a"," `",[451,770,772],{"class":771},"sVazx","json:\"title\"",[451,774,775],{"class":767},"`\n",[451,777,778,781,784,787,790],{"class":453,"line":496},[451,779,780],{"class":457},"    Published",[451,782,783],{"class":632}," bool",[451,785,786],{"class":767},"   `",[451,788,789],{"class":771},"json:\"published\"",[451,791,775],{"class":767},[451,793,794],{"class":453,"line":517},[451,795,796],{"class":480},"}\n",[451,798,799],{"class":453,"line":524},[451,800,521],{"emptyLinePlaceholder":520},[451,802,803,806,808,810,813,816,819,822,824,827,830,833,835,839],{"class":453,"line":551},[451,804,805],{"class":457},"lesson",[451,807,462],{"class":461},[451,809,750],{"class":628},[451,811,812],{"class":480},"{",[451,814,815],{"class":457},"Title",[451,817,818],{"class":480},":",[451,820,821],{"class":767}," \"",[451,823,255],{"class":771},[451,825,826],{"class":767},"\"",[451,828,829],{"class":480},",",[451,831,832],{"class":457}," Published",[451,834,818],{"class":480},[451,836,838],{"class":837},"sqQ1y"," true",[451,840,796],{"class":480},[451,842,843,845,847,849,851,853,855,857],{"class":453,"line":572},[451,844,472],{"class":457},[451,846,462],{"class":461},[451,848,477],{"class":457},[451,850,481],{"class":480},[451,852,485],{"class":484},[451,854,488],{"class":480},[451,856,805],{"class":457},[451,858,493],{"class":480},[451,860,862,864,866,869,871,873],{"class":453,"line":861},8,[451,863,499],{"class":457},[451,865,462],{"class":461},[451,867,868],{"class":457}," value",[451,870,481],{"class":480},[451,872,436],{"class":484},[451,874,875],{"class":480},"()\n",[451,877,879],{"class":453,"line":878},9,[451,880,521],{"emptyLinePlaceholder":520},[451,882,884,888,891,893,896,898,900,904,906,908,911,914,916,919],{"class":453,"line":883},10,[451,885,887],{"class":886},"s7Bcg","for",[451,889,890],{"class":457}," index",[451,892,462],{"class":461},[451,894,895],{"class":465}," 0",[451,897,411],{"class":480},[451,899,890],{"class":457},[451,901,903],{"class":902},"sRBoR"," \u003C",[451,905,868],{"class":457},[451,907,481],{"class":480},[451,909,910],{"class":484},"NumField",[451,912,913],{"class":480},"();",[451,915,890],{"class":457},[451,917,918],{"class":902},"++",[451,920,756],{"class":480},[451,922,924,927,929,932,934,937,939,942],{"class":453,"line":923},11,[451,925,926],{"class":457},"    fieldType",[451,928,462],{"class":461},[451,930,931],{"class":457}," typ",[451,933,481],{"class":480},[451,935,936],{"class":484},"Field",[451,938,488],{"class":480},[451,940,941],{"class":457},"index",[451,943,493],{"class":480},[451,945,947,950,952,954,956,958,960,962],{"class":453,"line":946},12,[451,948,949],{"class":457},"    fieldValue",[451,951,462],{"class":461},[451,953,868],{"class":457},[451,955,481],{"class":480},[451,957,936],{"class":484},[451,959,488],{"class":480},[451,961,941],{"class":457},[451,963,493],{"class":480},[451,965,967,970,972,974,976,979,981,983,985,988,990,993],{"class":453,"line":966},13,[451,968,969],{"class":457},"    fmt",[451,971,481],{"class":480},[451,973,532],{"class":484},[451,975,488],{"class":480},[451,977,978],{"class":457},"fieldType",[451,980,481],{"class":480},[451,982,541],{"class":457},[451,984,829],{"class":480},[451,986,987],{"class":457}," fieldValue",[451,989,481],{"class":480},[451,991,992],{"class":484},"Interface",[451,994,995],{"class":480},"())\n",[451,997,999],{"class":453,"line":998},14,[451,1000,796],{"class":480},[394,1002,1003,1005,1006,1009],{},[408,1004,992],{}," panics for values that cannot be interfaced, including certain unexported fields. A reusable library must inspect ",[408,1007,1008],{},"CanInterface"," and define how it handles unexported data.",[389,1011,1013],{"id":1012},"struct-tags-are-metadata-strings","Struct tags are metadata strings",[442,1015,1017],{"className":444,"code":1016,"language":446,"meta":447,"style":447},"field, _ := reflect.TypeOf(Lesson{}).FieldByName(\"Title\")\nname, options := field.Tag.Lookup(\"json\")\nfmt.Println(name, options)\n",[408,1018,1019,1058,1094],{"__ignoreMap":447},[451,1020,1021,1024,1026,1029,1031,1033,1035,1037,1039,1042,1045,1048,1050,1052,1054,1056],{"class":453,"line":454},[451,1022,1023],{"class":457},"field",[451,1025,829],{"class":480},[451,1027,1028],{"class":457}," _",[451,1030,462],{"class":461},[451,1032,477],{"class":457},[451,1034,481],{"class":480},[451,1036,508],{"class":484},[451,1038,488],{"class":480},[451,1040,1041],{"class":628},"Lesson",[451,1043,1044],{"class":480},"{}).",[451,1046,1047],{"class":484},"FieldByName",[451,1049,488],{"class":480},[451,1051,826],{"class":767},[451,1053,815],{"class":771},[451,1055,826],{"class":767},[451,1057,493],{"class":480},[451,1059,1060,1063,1065,1068,1070,1073,1075,1078,1080,1083,1085,1087,1090,1092],{"class":453,"line":469},[451,1061,1062],{"class":457},"name",[451,1064,829],{"class":480},[451,1066,1067],{"class":457}," options",[451,1069,462],{"class":461},[451,1071,1072],{"class":457}," field",[451,1074,481],{"class":480},[451,1076,1077],{"class":457},"Tag",[451,1079,481],{"class":480},[451,1081,1082],{"class":484},"Lookup",[451,1084,488],{"class":480},[451,1086,826],{"class":767},[451,1088,1089],{"class":771},"json",[451,1091,826],{"class":767},[451,1093,493],{"class":480},[451,1095,1096,1098,1100,1102,1104,1106,1108,1110],{"class":453,"line":496},[451,1097,527],{"class":457},[451,1099,481],{"class":480},[451,1101,532],{"class":484},[451,1103,488],{"class":480},[451,1105,1062],{"class":457},[451,1107,829],{"class":480},[451,1109,1067],{"class":457},[451,1111,493],{"class":480},[394,1113,1114,1115,1118],{},"A tag has no behaviour by itself. A package such as ",[408,1116,1117],{},"encoding\u002Fjson"," reads the tag and defines its meaning. Different packages can use different keys and rules.",[389,1120,1122],{"id":1121},"change-a-value","Change a value",[394,1124,1125,1126,1128],{},"This does not work because ",[408,1127,485],{}," received a copy:",[442,1130,1132],{"className":444,"code":1131,"language":446,"meta":447,"style":447},"lesson := Lesson{Title: \"Old\"}\nvalue := reflect.ValueOf(lesson)\nfmt.Println(value.CanSet()) \u002F\u002F false\n",[408,1133,1134,1157,1175],{"__ignoreMap":447},[451,1135,1136,1138,1140,1142,1144,1146,1148,1150,1153,1155],{"class":453,"line":454},[451,1137,805],{"class":457},[451,1139,462],{"class":461},[451,1141,750],{"class":628},[451,1143,812],{"class":480},[451,1145,815],{"class":457},[451,1147,818],{"class":480},[451,1149,821],{"class":767},[451,1151,1152],{"class":771},"Old",[451,1154,826],{"class":767},[451,1156,796],{"class":480},[451,1158,1159,1161,1163,1165,1167,1169,1171,1173],{"class":453,"line":469},[451,1160,472],{"class":457},[451,1162,462],{"class":461},[451,1164,477],{"class":457},[451,1166,481],{"class":480},[451,1168,485],{"class":484},[451,1170,488],{"class":480},[451,1172,805],{"class":457},[451,1174,493],{"class":480},[451,1176,1177,1179,1181,1183,1185,1187,1189,1192,1194],{"class":453,"line":496},[451,1178,527],{"class":457},[451,1180,481],{"class":480},[451,1182,532],{"class":484},[451,1184,488],{"class":480},[451,1186,472],{"class":457},[451,1188,481],{"class":480},[451,1190,1191],{"class":484},"CanSet",[451,1193,544],{"class":480},[451,1195,1196],{"class":547}," \u002F\u002F false\n",[394,1198,1199],{},"Pass a pointer and select the pointed-to value:",[442,1201,1203],{"className":444,"code":1202,"language":446,"meta":447,"style":447},"value := reflect.ValueOf(&lesson).Elem()\ntitle := value.FieldByName(\"Title\")\n\nif title.IsValid() && title.CanSet() && title.Kind() == reflect.String {\n    title.SetString(\"New\")\n}\n",[408,1204,1205,1232,1255,1259,1307,1328],{"__ignoreMap":447},[451,1206,1207,1209,1211,1213,1215,1217,1219,1222,1224,1227,1230],{"class":453,"line":454},[451,1208,472],{"class":457},[451,1210,462],{"class":461},[451,1212,477],{"class":457},[451,1214,481],{"class":480},[451,1216,485],{"class":484},[451,1218,488],{"class":480},[451,1220,1221],{"class":624},"&",[451,1223,805],{"class":457},[451,1225,1226],{"class":480},").",[451,1228,1229],{"class":484},"Elem",[451,1231,875],{"class":480},[451,1233,1234,1237,1239,1241,1243,1245,1247,1249,1251,1253],{"class":453,"line":469},[451,1235,1236],{"class":457},"title",[451,1238,462],{"class":461},[451,1240,868],{"class":457},[451,1242,481],{"class":480},[451,1244,1047],{"class":484},[451,1246,488],{"class":480},[451,1248,826],{"class":767},[451,1250,815],{"class":771},[451,1252,826],{"class":767},[451,1254,493],{"class":480},[451,1256,1257],{"class":453,"line":496},[451,1258,521],{"emptyLinePlaceholder":520},[451,1260,1261,1264,1267,1269,1271,1274,1277,1279,1281,1283,1285,1287,1289,1291,1293,1295,1298,1300,1302,1305],{"class":453,"line":517},[451,1262,1263],{"class":886},"if",[451,1265,1266],{"class":457}," title",[451,1268,481],{"class":480},[451,1270,720],{"class":484},[451,1272,1273],{"class":480},"()",[451,1275,1276],{"class":902}," &&",[451,1278,1266],{"class":457},[451,1280,481],{"class":480},[451,1282,1191],{"class":484},[451,1284,1273],{"class":480},[451,1286,1276],{"class":902},[451,1288,1266],{"class":457},[451,1290,481],{"class":480},[451,1292,410],{"class":484},[451,1294,1273],{"class":480},[451,1296,1297],{"class":902}," ==",[451,1299,477],{"class":457},[451,1301,481],{"class":480},[451,1303,1304],{"class":457},"String",[451,1306,756],{"class":480},[451,1308,1309,1312,1314,1317,1319,1321,1324,1326],{"class":453,"line":524},[451,1310,1311],{"class":457},"    title",[451,1313,481],{"class":480},[451,1315,1316],{"class":484},"SetString",[451,1318,488],{"class":480},[451,1320,826],{"class":767},[451,1322,1323],{"class":771},"New",[451,1325,826],{"class":767},[451,1327,493],{"class":480},[451,1329,1330],{"class":453,"line":551},[451,1331,796],{"class":480},[394,1333,1334],{},"A settable value must be addressable and permitted to change. Export rules still apply.",[389,1336,1338],{"id":1337},"contain-reflection-behind-typed-boundaries","Contain reflection behind typed boundaries",[394,1340,1341],{},"Bad public API:",[442,1343,1345],{"className":444,"code":1344,"language":446,"meta":447,"style":447},"func CopyAnything(dst, src any) error\n",[408,1346,1347],{"__ignoreMap":447},[451,1348,1349,1352,1355,1357,1361,1363,1366,1369,1372],{"class":453,"line":454},[451,1350,1351],{"class":624},"func",[451,1353,1354],{"class":484}," CopyAnything",[451,1356,488],{"class":480},[451,1358,1360],{"class":1359},"syre3","dst",[451,1362,829],{"class":480},[451,1364,1365],{"class":1359}," src",[451,1367,1368],{"class":628}," any",[451,1370,1371],{"class":480},")",[451,1373,1374],{"class":632}," error\n",[394,1376,1377],{},"The caller learns about mistakes only at runtime.",[394,1379,1380],{},"A better design may use generics, a small interface, code generation, or a typed wrapper around a reflective core. Validate inputs once and return clear errors naming the unsupported type or field.",[389,1382,1384],{"id":1383},"performance-and-caching","Performance and caching",[394,1386,1387,1388,1390],{},"Reflection adds runtime work and can allocate, but performance conclusions require measurement. If a profile identifies repeated type inspection as important, immutable metadata can be cached by ",[408,1389,599],{}," with concurrency-safe ownership.",[394,1392,1393,1394,1396],{},"Do not cache ",[408,1395,605],{}," objects that refer to short-lived mutable values without a precise lifetime design.",[389,1398,1400],{"id":1399},"common-mistakes","Common mistakes",[398,1402,1403,1413,1419,1425,1431],{},[401,1404,1405,1412],{},[1406,1407,1408,1409,1411],"strong",{},"Switching on ",[408,1410,410],{}," and forgetting defined types:"," kind describes representation, not full type identity.",[401,1414,1415,1418],{},[1406,1416,1417],{},"Calling methods before validity\u002Fkind checks:"," malformed input causes panics.",[401,1420,1421,1424],{},[1406,1422,1423],{},"Assuming tags enforce validation:"," only code interpreting the tag does anything.",[401,1426,1427,1430],{},[1406,1428,1429],{},"Reflecting over unexported fields casually:"," visibility rules and panic conditions still apply.",[401,1432,1433,1436],{},[1406,1434,1435],{},"Choosing reflection before interfaces or generics:"," callers lose compile-time guidance unnecessarily.",[389,1438,1440],{"id":1439},"practice","Practice",[394,1442,1443,1444,1447],{},"Write ",[408,1445,1446],{},"DescribeStruct(input any) ([]Field, error)"," that accepts a struct or pointer to struct and returns exported field names, types, kinds, and JSON tag names. Reject nil pointers and non-struct values without panicking.",[1449,1450,1451],"accordion",{},[1452,1453,1456,2166],"accordion-item",{"icon":1454,"label":1455},"i-lucide-lightbulb","Show solution",[442,1457,1459],{"className":444,"code":1458,"language":446,"meta":447,"style":447},"type Field struct {\n    Name     string\n    Type     string\n    Kind     reflect.Kind\n    JSONName string\n}\n\nfunc DescribeStruct(input any) ([]Field, error) {\n    value := reflect.ValueOf(input)\n    if !value.IsValid() {\n        return nil, errors.New(\"input is nil\")\n    }\n\n    if value.Kind() == reflect.Pointer {\n        if value.IsNil() {\n            return nil, errors.New(\"input is a nil pointer\")\n        }\n        value = value.Elem()\n    }\n\n    if value.Kind() != reflect.Struct {\n        return nil, fmt.Errorf(\"input has kind %s; want struct\", value.Kind())\n    }\n\n    typ := value.Type()\n    fields := make([]Field, 0, typ.NumField())\n    for index := 0; index \u003C typ.NumField(); index++ {\n        field := typ.Field(index)\n        if !field.IsExported() {\n            continue\n        }\n\n        jsonName := strings.Split(field.Tag.Get(\"json\"), \",\")[0]\n        if jsonName == \"-\" {\n            continue\n        }\n        if jsonName == \"\" {\n            jsonName = field.Name\n        }\n\n        fields = append(fields, Field{\n            Name: field.Name, Type: field.Type.String(), Kind: field.Type.Kind(), JSONName: jsonName,\n        })\n    }\n    return fields, nil\n}\n",[408,1460,1461,1472,1480,1487,1500,1508,1512,1516,1545,1564,1582,1611,1616,1620,1643,1659,1686,1692,1709,1714,1719,1744,1787,1792,1797,1813,1843,1875,1895,1913,1919,1924,1929,1984,2003,2008,2013,2027,2042,2047,2052,2075,2136,2142,2147,2161],{"__ignoreMap":447},[451,1462,1463,1465,1468,1470],{"class":453,"line":454},[451,1464,625],{"class":624},[451,1466,1467],{"class":628}," Field",[451,1469,753],{"class":624},[451,1471,756],{"class":480},[451,1473,1474,1477],{"class":453,"line":469},[451,1475,1476],{"class":457},"    Name",[451,1478,1479],{"class":632},"     string\n",[451,1481,1482,1485],{"class":453,"line":496},[451,1483,1484],{"class":457},"    Type",[451,1486,1479],{"class":632},[451,1488,1489,1492,1495,1497],{"class":453,"line":517},[451,1490,1491],{"class":457},"    Kind",[451,1493,1494],{"class":628},"     reflect",[451,1496,481],{"class":480},[451,1498,1499],{"class":628},"Kind\n",[451,1501,1502,1505],{"class":453,"line":524},[451,1503,1504],{"class":457},"    JSONName",[451,1506,1507],{"class":632}," string\n",[451,1509,1510],{"class":453,"line":551},[451,1511,796],{"class":480},[451,1513,1514],{"class":453,"line":572},[451,1515,521],{"emptyLinePlaceholder":520},[451,1517,1518,1520,1523,1525,1527,1529,1531,1534,1536,1538,1541,1543],{"class":453,"line":861},[451,1519,1351],{"class":624},[451,1521,1522],{"class":484}," DescribeStruct",[451,1524,488],{"class":480},[451,1526,458],{"class":1359},[451,1528,1368],{"class":628},[451,1530,1371],{"class":480},[451,1532,1533],{"class":480}," ([]",[451,1535,936],{"class":628},[451,1537,829],{"class":480},[451,1539,1540],{"class":632}," error",[451,1542,1371],{"class":480},[451,1544,756],{"class":480},[451,1546,1547,1550,1552,1554,1556,1558,1560,1562],{"class":453,"line":878},[451,1548,1549],{"class":457},"    value",[451,1551,462],{"class":461},[451,1553,477],{"class":457},[451,1555,481],{"class":480},[451,1557,485],{"class":484},[451,1559,488],{"class":480},[451,1561,458],{"class":457},[451,1563,493],{"class":480},[451,1565,1566,1569,1572,1574,1576,1578,1580],{"class":453,"line":883},[451,1567,1568],{"class":886},"    if",[451,1570,1571],{"class":902}," !",[451,1573,472],{"class":457},[451,1575,481],{"class":480},[451,1577,720],{"class":484},[451,1579,1273],{"class":480},[451,1581,756],{"class":480},[451,1583,1584,1587,1591,1593,1596,1598,1600,1602,1604,1607,1609],{"class":453,"line":923},[451,1585,1586],{"class":886},"        return",[451,1588,1590],{"class":1589},"sp8Z5"," nil",[451,1592,829],{"class":480},[451,1594,1595],{"class":457}," errors",[451,1597,481],{"class":480},[451,1599,1323],{"class":484},[451,1601,488],{"class":480},[451,1603,826],{"class":767},[451,1605,1606],{"class":771},"input is nil",[451,1608,826],{"class":767},[451,1610,493],{"class":480},[451,1612,1613],{"class":453,"line":946},[451,1614,1615],{"class":480},"    }\n",[451,1617,1618],{"class":453,"line":966},[451,1619,521],{"emptyLinePlaceholder":520},[451,1621,1622,1624,1626,1628,1630,1632,1634,1636,1638,1641],{"class":453,"line":998},[451,1623,1568],{"class":886},[451,1625,868],{"class":457},[451,1627,481],{"class":480},[451,1629,410],{"class":484},[451,1631,1273],{"class":480},[451,1633,1297],{"class":902},[451,1635,477],{"class":457},[451,1637,481],{"class":480},[451,1639,1640],{"class":457},"Pointer",[451,1642,756],{"class":480},[451,1644,1646,1649,1651,1653,1655,1657],{"class":453,"line":1645},15,[451,1647,1648],{"class":886},"        if",[451,1650,868],{"class":457},[451,1652,481],{"class":480},[451,1654,727],{"class":484},[451,1656,1273],{"class":480},[451,1658,756],{"class":480},[451,1660,1662,1665,1667,1669,1671,1673,1675,1677,1679,1682,1684],{"class":453,"line":1661},16,[451,1663,1664],{"class":886},"            return",[451,1666,1590],{"class":1589},[451,1668,829],{"class":480},[451,1670,1595],{"class":457},[451,1672,481],{"class":480},[451,1674,1323],{"class":484},[451,1676,488],{"class":480},[451,1678,826],{"class":767},[451,1680,1681],{"class":771},"input is a nil pointer",[451,1683,826],{"class":767},[451,1685,493],{"class":480},[451,1687,1689],{"class":453,"line":1688},17,[451,1690,1691],{"class":480},"        }\n",[451,1693,1695,1698,1701,1703,1705,1707],{"class":453,"line":1694},18,[451,1696,1697],{"class":457},"        value",[451,1699,1700],{"class":461}," =",[451,1702,868],{"class":457},[451,1704,481],{"class":480},[451,1706,1229],{"class":484},[451,1708,875],{"class":480},[451,1710,1712],{"class":453,"line":1711},19,[451,1713,1615],{"class":480},[451,1715,1717],{"class":453,"line":1716},20,[451,1718,521],{"emptyLinePlaceholder":520},[451,1720,1722,1724,1726,1728,1730,1732,1735,1737,1739,1742],{"class":453,"line":1721},21,[451,1723,1568],{"class":886},[451,1725,868],{"class":457},[451,1727,481],{"class":480},[451,1729,410],{"class":484},[451,1731,1273],{"class":480},[451,1733,1734],{"class":902}," !=",[451,1736,477],{"class":457},[451,1738,481],{"class":480},[451,1740,1741],{"class":457},"Struct",[451,1743,756],{"class":480},[451,1745,1747,1749,1751,1753,1756,1758,1761,1763,1765,1768,1772,1775,1777,1779,1781,1783,1785],{"class":453,"line":1746},22,[451,1748,1586],{"class":886},[451,1750,1590],{"class":1589},[451,1752,829],{"class":480},[451,1754,1755],{"class":457}," fmt",[451,1757,481],{"class":480},[451,1759,1760],{"class":484},"Errorf",[451,1762,488],{"class":480},[451,1764,826],{"class":767},[451,1766,1767],{"class":771},"input has kind ",[451,1769,1771],{"class":1770},"st3jj","%s",[451,1773,1774],{"class":771},"; want struct",[451,1776,826],{"class":767},[451,1778,829],{"class":480},[451,1780,868],{"class":457},[451,1782,481],{"class":480},[451,1784,410],{"class":484},[451,1786,995],{"class":480},[451,1788,1790],{"class":453,"line":1789},23,[451,1791,1615],{"class":480},[451,1793,1795],{"class":453,"line":1794},24,[451,1796,521],{"emptyLinePlaceholder":520},[451,1798,1800,1803,1805,1807,1809,1811],{"class":453,"line":1799},25,[451,1801,1802],{"class":457},"    typ",[451,1804,462],{"class":461},[451,1806,868],{"class":457},[451,1808,481],{"class":480},[451,1810,436],{"class":484},[451,1812,875],{"class":480},[451,1814,1816,1819,1821,1824,1827,1829,1831,1833,1835,1837,1839,1841],{"class":453,"line":1815},26,[451,1817,1818],{"class":457},"    fields",[451,1820,462],{"class":461},[451,1822,1823],{"class":484}," make",[451,1825,1826],{"class":480},"([]",[451,1828,936],{"class":628},[451,1830,829],{"class":480},[451,1832,895],{"class":465},[451,1834,829],{"class":480},[451,1836,931],{"class":457},[451,1838,481],{"class":480},[451,1840,910],{"class":484},[451,1842,995],{"class":480},[451,1844,1846,1849,1851,1853,1855,1857,1859,1861,1863,1865,1867,1869,1871,1873],{"class":453,"line":1845},27,[451,1847,1848],{"class":886},"    for",[451,1850,890],{"class":457},[451,1852,462],{"class":461},[451,1854,895],{"class":465},[451,1856,411],{"class":480},[451,1858,890],{"class":457},[451,1860,903],{"class":902},[451,1862,931],{"class":457},[451,1864,481],{"class":480},[451,1866,910],{"class":484},[451,1868,913],{"class":480},[451,1870,890],{"class":457},[451,1872,918],{"class":902},[451,1874,756],{"class":480},[451,1876,1878,1881,1883,1885,1887,1889,1891,1893],{"class":453,"line":1877},28,[451,1879,1880],{"class":457},"        field",[451,1882,462],{"class":461},[451,1884,931],{"class":457},[451,1886,481],{"class":480},[451,1888,936],{"class":484},[451,1890,488],{"class":480},[451,1892,941],{"class":457},[451,1894,493],{"class":480},[451,1896,1898,1900,1902,1904,1906,1909,1911],{"class":453,"line":1897},29,[451,1899,1648],{"class":886},[451,1901,1571],{"class":902},[451,1903,1023],{"class":457},[451,1905,481],{"class":480},[451,1907,1908],{"class":484},"IsExported",[451,1910,1273],{"class":480},[451,1912,756],{"class":480},[451,1914,1916],{"class":453,"line":1915},30,[451,1917,1918],{"class":886},"            continue\n",[451,1920,1922],{"class":453,"line":1921},31,[451,1923,1691],{"class":480},[451,1925,1927],{"class":453,"line":1926},32,[451,1928,521],{"emptyLinePlaceholder":520},[451,1930,1932,1935,1937,1940,1942,1945,1947,1949,1951,1953,1955,1958,1960,1962,1964,1966,1969,1971,1973,1975,1978,1981],{"class":453,"line":1931},33,[451,1933,1934],{"class":457},"        jsonName",[451,1936,462],{"class":461},[451,1938,1939],{"class":457}," strings",[451,1941,481],{"class":480},[451,1943,1944],{"class":484},"Split",[451,1946,488],{"class":480},[451,1948,1023],{"class":457},[451,1950,481],{"class":480},[451,1952,1077],{"class":457},[451,1954,481],{"class":480},[451,1956,1957],{"class":484},"Get",[451,1959,488],{"class":480},[451,1961,826],{"class":767},[451,1963,1089],{"class":771},[451,1965,826],{"class":767},[451,1967,1968],{"class":480},"),",[451,1970,821],{"class":767},[451,1972,829],{"class":771},[451,1974,826],{"class":767},[451,1976,1977],{"class":480},")[",[451,1979,1980],{"class":465},"0",[451,1982,1983],{"class":480},"]\n",[451,1985,1987,1989,1992,1994,1996,1999,2001],{"class":453,"line":1986},34,[451,1988,1648],{"class":886},[451,1990,1991],{"class":457}," jsonName",[451,1993,1297],{"class":902},[451,1995,821],{"class":767},[451,1997,1998],{"class":771},"-",[451,2000,826],{"class":767},[451,2002,756],{"class":480},[451,2004,2006],{"class":453,"line":2005},35,[451,2007,1918],{"class":886},[451,2009,2011],{"class":453,"line":2010},36,[451,2012,1691],{"class":480},[451,2014,2016,2018,2020,2022,2025],{"class":453,"line":2015},37,[451,2017,1648],{"class":886},[451,2019,1991],{"class":457},[451,2021,1297],{"class":902},[451,2023,2024],{"class":767}," \"\"",[451,2026,756],{"class":480},[451,2028,2030,2033,2035,2037,2039],{"class":453,"line":2029},38,[451,2031,2032],{"class":457},"            jsonName",[451,2034,1700],{"class":461},[451,2036,1072],{"class":457},[451,2038,481],{"class":480},[451,2040,2041],{"class":457},"Name\n",[451,2043,2045],{"class":453,"line":2044},39,[451,2046,1691],{"class":480},[451,2048,2050],{"class":453,"line":2049},40,[451,2051,521],{"emptyLinePlaceholder":520},[451,2053,2055,2058,2060,2063,2065,2068,2070,2072],{"class":453,"line":2054},41,[451,2056,2057],{"class":457},"        fields",[451,2059,1700],{"class":461},[451,2061,2062],{"class":484}," append",[451,2064,488],{"class":480},[451,2066,2067],{"class":457},"fields",[451,2069,829],{"class":480},[451,2071,1467],{"class":628},[451,2073,2074],{"class":480},"{\n",[451,2076,2078,2081,2083,2085,2087,2089,2091,2094,2096,2098,2100,2102,2104,2106,2109,2112,2114,2116,2118,2120,2122,2124,2126,2129,2131,2133],{"class":453,"line":2077},42,[451,2079,2080],{"class":457},"            Name",[451,2082,818],{"class":480},[451,2084,1072],{"class":457},[451,2086,481],{"class":480},[451,2088,541],{"class":457},[451,2090,829],{"class":480},[451,2092,2093],{"class":457}," Type",[451,2095,818],{"class":480},[451,2097,1072],{"class":457},[451,2099,481],{"class":480},[451,2101,436],{"class":457},[451,2103,481],{"class":480},[451,2105,1304],{"class":484},[451,2107,2108],{"class":480},"(),",[451,2110,2111],{"class":457}," Kind",[451,2113,818],{"class":480},[451,2115,1072],{"class":457},[451,2117,481],{"class":480},[451,2119,436],{"class":457},[451,2121,481],{"class":480},[451,2123,410],{"class":484},[451,2125,2108],{"class":480},[451,2127,2128],{"class":457}," JSONName",[451,2130,818],{"class":480},[451,2132,1991],{"class":457},[451,2134,2135],{"class":480},",\n",[451,2137,2139],{"class":453,"line":2138},43,[451,2140,2141],{"class":480},"        })\n",[451,2143,2145],{"class":453,"line":2144},44,[451,2146,1615],{"class":480},[451,2148,2150,2153,2156,2158],{"class":453,"line":2149},45,[451,2151,2152],{"class":886},"    return",[451,2154,2155],{"class":457}," fields",[451,2157,829],{"class":480},[451,2159,2160],{"class":1589}," nil\n",[451,2162,2164],{"class":453,"line":2163},46,[451,2165,796],{"class":480},[394,2167,2168],{},"This solution checks every precondition before operations that would panic. A production tag parser may need more complete handling of embedded fields and package-specific tag rules; those behaviours should be documented and tested rather than guessed.",[389,2170,2172],{"id":2171},"summary","Summary",[398,2174,2175,2178,2184,2187,2190],{},[401,2176,2177],{},"Reflection inspects runtime types and values at the cost of compile-time guarantees.",[401,2179,2180,2181,2183],{},"Type identity and ",[408,2182,410],{}," answer different questions.",[401,2185,2186],{},"Check validity, nil, kind, interface access, and settability before operating.",[401,2188,2189],{},"Struct tags are inert metadata interpreted by packages.",[401,2191,2192],{},"Prefer typed APIs and contain any reflective core behind validation and tests.",[394,2194,2195,2196,481],{},"Official reference: ",[2197,2198,2202,2205],"a",{"href":2199,"rel":2200},"https:\u002F\u002Fpkg.go.dev\u002Freflect",[2201],"nofollow",[408,2203,2204],{},"reflect"," package documentation",[2207,2208],"learning-lesson-complete",{},[2210,2211],"learning-lesson-navigation",{"next":261,"next-label":260,"previous":251,"previous-label":250},[2213,2214,2215],"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 .su2KV, html code.shiki .su2KV{--shiki-light:#859900;--shiki-default:#89DDFF;--shiki-dark:#E5C07B}html pre.shiki code .sAJzr, html code.shiki .sAJzr{--shiki-light:#D33682;--shiki-default:#F78C6C;--shiki-dark:#D19A66}html pre.shiki code .shFME, html code.shiki .shFME{--shiki-light:#657B83;--shiki-default:#89DDFF;--shiki-dark:#ABB2BF}html pre.shiki code .sisdC, html code.shiki .sisdC{--shiki-light:#268BD2;--shiki-default:#82AAFF;--shiki-dark:#61AFEF}html pre.shiki code .sJsHy, html code.shiki .sJsHy{--shiki-light:#93A1A1;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic}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 .snwKR, html code.shiki .snwKR{--shiki-light:#CB4B16;--shiki-default:#FFCB6B;--shiki-dark:#E5C07B}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 .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 .sqQ1y, html code.shiki .sqQ1y{--shiki-light:#B58900;--shiki-default:#FF9CAC;--shiki-dark:#D19A66}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 .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 .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}",{"title":447,"searchDepth":469,"depth":469,"links":2217},[2218,2219,2220,2222,2223,2224,2225,2226,2227,2228,2229,2230],{"id":391,"depth":469,"text":392},{"id":423,"depth":469,"text":424},{"id":433,"depth":469,"text":2221},"Type and Value",{"id":707,"depth":469,"text":708},{"id":737,"depth":469,"text":738},{"id":1012,"depth":469,"text":1013},{"id":1121,"depth":469,"text":1122},{"id":1337,"depth":469,"text":1338},{"id":1383,"depth":469,"text":1384},{"id":1399,"depth":469,"text":1400},{"id":1439,"depth":469,"text":1440},{"id":2171,"depth":469,"text":2172},"Inspect types and values at runtime while containing panics, complexity, and lost type safety.","md",null,{},{"icon":258},{"description":2237,"title":255},"Learn Go reflection with Type, Value, Kind, addressability, settability, struct tags, safe APIs, and alternatives.","nqfcqzaHK5a4Lm6MiPyAdt0MGHhfiHc_UMGlT5z05Q4",[2240,2242],{"title":250,"path":251,"stem":252,"description":2241,"icon":253,"children":-1},"Move from writing correct Go to reasoning about runtime behaviour, performance, APIs, and system boundaries.",{"title":260,"path":261,"stem":262,"description":2243,"icon":263,"children":-1},"Reason about reachability, escape analysis, allocation, retention, and resource cleanup without relying on myths.",1794118102925]