Re:Map[string]interface{} in Go: a user's manual
by tptacek on Monday July 26, 2021 @06:28PM
(#27966254)
Right, which is why json.Unmarshal returns an error, and why map lookups return an extra `ok` value in Go.
[ Parent
| on HN ]
Re:Map[string]interface{} in Go: a user's manual
by tgsovlerkhgsel on Monday July 26, 2021 @07:03PM
(#27966569)
It would be a lot more than 4 lines in Go though. Either the struct definition, or a lot of `if !ok return error`. Especially once the nesting gets deeper.
Re:Map[string]interface{} in Go: a user's manual
by tptacek on Monday July 26, 2021 @07:29PM
(#27966797)
I'm pretty sure it would just be an `if err != nil {http.Error(w, err.Error(), 501); return }`.
Re:Map[string]interface{} in Go: a user's manual
by tgsovlerkhgsel on Monday July 26, 2021 @11:19PM
(#27968251)
one of these for each nesting level.