Hacker News new | ask | show | jobs
by zimpenfish 102 days ago
> The only at least somewhat feasible solution that I could see

You can use pointers and then `encoding/json` will leave them as `nil` if the field is missing when you `Unmarshal`. I believe the AWS Go SDK uses this technique for "optional" fields (both input and output.) Obviously more of a faff than if it supported truly "unset" fields but it is what it is.

(see https://go.dev/play/p/rkLqnEmyuVE )