MutterCorp
MutterCorpNotice · Notícias
Programação·

Go's encoding/json/v2 Changes Six Defaults You Probably Rely On

Go's encoding/json/v2 Changes Six Defaults You Probably Rely On

Picture a short program that should make you pause. You marshal a slice of structs, one of which has a nil slice field. On v1 the output contains "Nicknames":null. Switch the import to encoding/json/v2 and it prints "Nicknames":[]. The code compiles either way, the tests you wrote for the happy path still pass, and a downstream service that treats null and [] differently quietly starts misbehaving. That example comes straight from Go's own migration guide, and it is the right mental model for t…

Publicado no Notice. Categoria: Programação.

Notícias sobre o mesmo assunto em outras fontes