Documentation ¶
Overview ¶
Package optional defines optional versions of primitive types that can be nil. These are useful when performing partial updates of some objects because it is impossible to tell the difference between a value that is explicitly set to its zero value and a value that is not set at all when marshaling a struct with native primitive types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool represents an optional boolean value.
func (*Bool) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int represents an optional int.
func (*Int) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String represents an optional string.
func NewNilString ¶
func NewNilString() *String
NewNilString returns a new optional string set to nil.
func (*String) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type StringSlice ¶
type StringSlice struct {
// contains filtered or unexported fields
}
StringSlice represents an optional string slice.
func NewNilStringSlice ¶
func NewNilStringSlice() *StringSlice
NewNilStringSlice returns a new optional string slice set to nil.
func NewStringSlice ¶
func NewStringSlice(ss []string) *StringSlice
NewStringSlice returns a new optional string slice set to ss. If ss is nil, it is equivalent to NewNilStringSlice.
func (*StringSlice) MarshalJSON ¶
func (s *StringSlice) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.