mirror of
https://github.com/moby/moby.git
synced 2026-08-09 17:39:58 +00:00
Pull request 50956 (88adc28731) updated various types in the API module from a string to a `netip.Prefix` or `netip.Addr`. A side-effect of this was that zero values would no longer be omitted, and instead marshaled as an empty string; package main import ( "encoding/json" "fmt" "net/netip" ) type Foo struct { OmitEmpty netip.Prefix `json:",omitempty"` OmitZero netip.Prefix `json:",omitzero"` } func main() { out, _ := json.Marshal(Foo{}) fmt.Println(string(out)) } The above produces `{"OmitEmpty":""}`, not omitting the empty address. This patch; - updates most types to use `omitzero` instead of `omitempty`. - adds explicit `json` names to fields. There's one type remaining that uses `omitzero`, but it's generated by go-swagger, which currently doesn't support `omitzero`; the `PortSummary.IP`;335f60509f/api/types/container/port_summary.go (L12-L20)Signed-off-by: Sebastiaan van Stijn <github@gone.nl>