-
Notifications
You must be signed in to change notification settings - Fork 280
Description
Originally posted by @mdbooth in #1729 (comment)
After offline discussion with @JoelSpeed about this, I think I understand a new API principal: omitempty
is only for struct pointers. IOW we're massively over-using it.
I'd like this to be another v1beta1 cleanup: remove omitempty from all values which aren't struct pointers. Unfortunately this may mean turning some structs (back) into pointers if we want to ensure they're omitted, which I hate because Go makes struct pointers in large data structures a syntactic minefield1.
Footnotes
-
Because it doesn't require a
->
operator like more civilised pointer languages, it's impossible to visually distinguish a pointer dereference from regular access of a struct field, which means it's easy to miss that you need a null check. Even worse, turning a struct into a struct pointer won't break compilation of existing references, meaning they will all have to be checked manually when making this change. ↩