OptionalObject is for situations where we want to differentiate between an empty object, and the object not having been set. An example would be an optional command line option where we want to tell the difference between it being set to an empty object, and it not being specified at all.
| 7 | // optional command line option where we want to tell the difference between |
| 8 | // it being set to an empty object, and it not being specified at all. |
| 9 | type OptionalObject struct { |
| 10 | IsSet bool |
| 11 | Value map[string]interface{} |
| 12 | } |
| 13 | |
| 14 | func NewOptionalObject(v map[string]interface{}) OptionalObject { |
| 15 | if v == nil { |