Unlink maps, slices can be used without having been allocated:
A Go channel cannot be closed twice, doing so will panic…
It is obviously better to have a single path managing the lifecycle of a channel, creating the channel at the beginning and closing it at the end, but channels enable interesting signaling patterns where…
It is sometimes necessary to work with JSON objects using a dynamic schema : optional fields, fields having dynamic types, …
In this first part, we’ll start with the easy part : generating JSON with optional…
[EDIT 10/30/2015 : rewrote most of the post for clarity and exactitude]
Everybody knows Go favors composition over inheritance. But Go also something that looks a little bit like method overriding, one feature of inheritance.
The Go JSON encoder is great (easy to use and easy to extend), except for a tiny thing : zero times which marshal to “0001–01–01T00:00:00Z” instead of something like null. Yuck !
enc := json.NewEncoder(os.Stdout)enc.Encode(time.Time{}) //…