Re: [go-nuts] Structs for JSON APIs and required fields... using pointers

2020-10-30 Thread Marcin Romaszewicz
I don't know if there's any standard practice to it. If the meaning of the zero value and "not present" is different in your application, then clearly, you can't use the zero value as you can't tell them apart, while you can with a pointer. The sql package does it with a version of optionals (https

[go-nuts] Structs for JSON APIs and required fields... using pointers

2020-10-30 Thread Trig
What is the standard practice between required fields of a struct you're expecting to deserialize using JSON, and using pointers for this (if there's any correlation)? API defined a string as required. Do you define it as a string and check for zero-value for that type, or *string and check fo