Being confused about nil vs. empty slice (#22)
Official 100go entry on API and encoding differences between `nil` and empty slices.
Official 100go entry on API and encoding differences between nil and empty slices.
- Author: Teiva Harsanyi
- Authority: community
- Kind: guide
- URL: https://100go.co/#being-confused-about-nil-vs-empty-slice-22
What it covers
- nil vs empty semantics
- API return choices
- encoding-visible differences
Why authoritative
Official 100go website entry for this specific mistake.
Use when
- should this function return nil or empty slice
- what is the difference between nil and empty slice in Go
- does JSON treat nil and empty slices differently
Keywords
- nil slice, empty slice, JSON, API design, slice semantics