What is the zero value of a pointer, map, slice, and channel in Go, and why does this matter for SRE tooling that reads config structs?
#Reveal answer guidance
All four have a zero value of nil. A nil pointer dereference panics; a nil map read returns the zero value of the value type (safe) but a nil map write panics; a nil slice is safe to range over and append to; a nil channel blocks forever on send/receive. For SRE config structs, you must guard map writes (if cfg.Labels == nil { cfg.Labels = make(map[string]string) }) and always check pointers before dereferencing. Unmarshalling JSON/YAML into a struct with pointer fields is safe — the decoder allocates — but hand-constructed structs are not.