Re:A New Go API for JSON
by throwaway894345 on Wednesday November 04, 2026 @11:15PM
(#50375100)
How is this a broken default? In Go, I almost always want a nil slice to be treated exactly as an empty slice, and JSONv1 was the ~only place this didn’t work as expected, leading to frequent bugs.
[ Parent
| on HN ]
Re:A New Go API for JSON
by c-hendricks on Thursday November 05, 2026 @09:52AM
(#50379813)
JSON often means data is crossing a boundary, and JSON has `null`. So if you have a PATCH endpoint that accepts a partial object, how do you determine what was actually set in the request vs what go has initialized to an empty value.
Re:A New Go API for JSON
by throwaway894345 on Thursday November 05, 2026 @11:28AM
(#50381131)
Use the same `Option[T]` type that you will need to define for strings and numbers and structs.
Re:A New Go API for JSON
by c-hendricks on Thursday November 05, 2026 @04:08PM
(#50384475)
What was the solution before go had generics? I thought it was nil pointers.
Re:A New Go API for JSON
by throwaway894345 on Thursday November 05, 2026 @04:20PM
(#50384611)
I don’t think there was a single canonical solution, but pointers to everything was a pretty common one. Everything in the AWS SDK was a `string` or a `float64` or similar—it was exceedingly annoying, not least of all because it basically forced tons of unnecessary allocations.