Documentation ¶
Overview ¶
Example (Get) ¶
package main import ( "fmt" "github.com/yaamai/optional" ) func main() { values := []optional.String{ optional.NewString("foo"), optional.NewString(""), optional.NewString("bar"), {}, } for _, v := range values { value, err := v.Get() if err != nil { fmt.Println(err.Error()) } else { fmt.Println(value) } } }
Output: foo bar value not present
Example (If) ¶
package main import ( "fmt" "github.com/yaamai/optional" ) func main() { values := []optional.String{ optional.NewString("foo"), optional.NewString(""), optional.NewString("bar"), {}, } for _, v := range values { v.If(func(s string) { fmt.Println("present") }) } }
Output: present present present
Example (MarshalJSON) ¶
package main import ( "encoding/json" "fmt" "github.com/yaamai/optional" ) func main() { type example struct { Field *optional.String `json:"field,omitempty"` FieldTwo *optional.String `json:"field_two"` } var values = []optional.String{ optional.NewString("foo"), optional.NewString(""), optional.NewString("bar"), } for _, v := range values { out, _ := json.Marshal(&example{ Field: &v, FieldTwo: &v, }) fmt.Println(string(out)) } out, _ := json.Marshal(&example{}) fmt.Println(string(out)) }
Output: {"field":"foo","field_two":"foo"} {"field":"","field_two":""} {"field":"bar","field_two":"bar"} {"field_two":null}
Example (OrElse) ¶
package main import ( "fmt" "github.com/yaamai/optional" ) func main() { values := []optional.String{ optional.NewString("foo"), optional.NewString(""), optional.NewString("bar"), {}, } for _, v := range values { fmt.Println(v.OrElse("not present")) } }
Output: foo bar not present
Example (Set) ¶
package main import ( "fmt" "github.com/yaamai/optional" ) func main() { var ( values = []string{ "foo", "", "bar", } s = optional.NewString("baz") ) for _, v := range values { s.Set(v) value, err := s.Get() if err != nil { fmt.Println(err.Error()) } else { fmt.Println(value) } } }
Output: foo bar
Example (UnmarshalJSON) ¶
package main import ( "encoding/json" "fmt" "github.com/yaamai/optional" ) func main() { var values = []string{ `{"field":"foo","field_two":"foo"}`, `{"field":"","field_two":""}`, `{"field":"null","field_two":"null"}`, `{"field":"bar","field_two":"bar"}`, "{}", } for _, v := range values { var o = &struct { Field optional.String `json:"field,omitempty"` FieldTwo optional.String `json:"field_two"` }{} if err := json.Unmarshal([]byte(v), o); err != nil { fmt.Println(err) } o.Field.If(func(s string) { fmt.Println(s) }) o.FieldTwo.If(func(s string) { fmt.Println(s) }) }
Output:
Index ¶
- type Bool
- func (b Bool) Get() (bool, error)
- func (b Bool) If(fn func(bool))
- func (b Bool) MarshalJSON() ([]byte, error)
- func (b Bool) MarshalYAML() ([]byte, error)
- func (b Bool) OrElse(v bool) bool
- func (b Bool) Present() bool
- func (b *Bool) Set(v bool)
- func (b *Bool) UnmarshalJSON(data []byte) error
- func (b *Bool) UnmarshalYAML(data []byte) error
- func (b Bool) Unwrap() bool
- type Byte
- func (b Byte) Get() (byte, error)
- func (b Byte) If(fn func(byte))
- func (b Byte) MarshalJSON() ([]byte, error)
- func (b Byte) MarshalYAML() ([]byte, error)
- func (b Byte) OrElse(v byte) byte
- func (b Byte) Present() bool
- func (b *Byte) Set(v byte)
- func (b *Byte) UnmarshalJSON(data []byte) error
- func (b *Byte) UnmarshalYAML(data []byte) error
- func (b Byte) Unwrap() byte
- type Complex128
- func (c Complex128) Get() (complex128, error)
- func (c Complex128) If(fn func(complex128))
- func (c Complex128) MarshalJSON() ([]byte, error)
- func (c Complex128) MarshalYAML() ([]byte, error)
- func (c Complex128) OrElse(v complex128) complex128
- func (c Complex128) Present() bool
- func (c *Complex128) Set(v complex128)
- func (c *Complex128) UnmarshalJSON(data []byte) error
- func (c *Complex128) UnmarshalYAML(data []byte) error
- func (c Complex128) Unwrap() complex128
- type Complex64
- func (c Complex64) Get() (complex64, error)
- func (c Complex64) If(fn func(complex64))
- func (c Complex64) MarshalJSON() ([]byte, error)
- func (c Complex64) MarshalYAML() ([]byte, error)
- func (c Complex64) OrElse(v complex64) complex64
- func (c Complex64) Present() bool
- func (c *Complex64) Set(v complex64)
- func (c *Complex64) UnmarshalJSON(data []byte) error
- func (c *Complex64) UnmarshalYAML(data []byte) error
- func (c Complex64) Unwrap() complex64
- type Error
- func (e Error) Get() (error, error)
- func (e Error) If(fn func(error))
- func (e Error) MarshalJSON() ([]byte, error)
- func (e Error) MarshalYAML() ([]byte, error)
- func (e Error) OrElse(v error) error
- func (e Error) Present() bool
- func (e *Error) Set(v error)
- func (e *Error) UnmarshalJSON(data []byte) error
- func (e *Error) UnmarshalYAML(data []byte) error
- func (e Error) Unwrap() error
- type Float32
- func (f Float32) Get() (float32, error)
- func (f Float32) If(fn func(float32))
- func (f Float32) MarshalJSON() ([]byte, error)
- func (f Float32) MarshalYAML() ([]byte, error)
- func (f Float32) OrElse(v float32) float32
- func (f Float32) Present() bool
- func (f *Float32) Set(v float32)
- func (f *Float32) UnmarshalJSON(data []byte) error
- func (f *Float32) UnmarshalYAML(data []byte) error
- func (f Float32) Unwrap() float32
- type Float64
- func (f Float64) Get() (float64, error)
- func (f Float64) If(fn func(float64))
- func (f Float64) MarshalJSON() ([]byte, error)
- func (f Float64) MarshalYAML() ([]byte, error)
- func (f Float64) OrElse(v float64) float64
- func (f Float64) Present() bool
- func (f *Float64) Set(v float64)
- func (f *Float64) UnmarshalJSON(data []byte) error
- func (f *Float64) UnmarshalYAML(data []byte) error
- func (f Float64) Unwrap() float64
- type Int
- func (i Int) Get() (int, error)
- func (i Int) If(fn func(int))
- func (i Int) MarshalJSON() ([]byte, error)
- func (i Int) MarshalYAML() ([]byte, error)
- func (i Int) OrElse(v int) int
- func (i Int) Present() bool
- func (i *Int) Set(v int)
- func (i *Int) UnmarshalJSON(data []byte) error
- func (i *Int) UnmarshalYAML(data []byte) error
- func (i Int) Unwrap() int
- type Int16
- func (i Int16) Get() (int16, error)
- func (i Int16) If(fn func(int16))
- func (i Int16) MarshalJSON() ([]byte, error)
- func (i Int16) MarshalYAML() ([]byte, error)
- func (i Int16) OrElse(v int16) int16
- func (i Int16) Present() bool
- func (i *Int16) Set(v int16)
- func (i *Int16) UnmarshalJSON(data []byte) error
- func (i *Int16) UnmarshalYAML(data []byte) error
- func (i Int16) Unwrap() int16
- type Int32
- func (i Int32) Get() (int32, error)
- func (i Int32) If(fn func(int32))
- func (i Int32) MarshalJSON() ([]byte, error)
- func (i Int32) MarshalYAML() ([]byte, error)
- func (i Int32) OrElse(v int32) int32
- func (i Int32) Present() bool
- func (i *Int32) Set(v int32)
- func (i *Int32) UnmarshalJSON(data []byte) error
- func (i *Int32) UnmarshalYAML(data []byte) error
- func (i Int32) Unwrap() int32
- type Int64
- func (i Int64) Get() (int64, error)
- func (i Int64) If(fn func(int64))
- func (i Int64) MarshalJSON() ([]byte, error)
- func (i Int64) MarshalYAML() ([]byte, error)
- func (i Int64) OrElse(v int64) int64
- func (i Int64) Present() bool
- func (i *Int64) Set(v int64)
- func (i *Int64) UnmarshalJSON(data []byte) error
- func (i *Int64) UnmarshalYAML(data []byte) error
- func (i Int64) Unwrap() int64
- type Int8
- func (i Int8) Get() (int8, error)
- func (i Int8) If(fn func(int8))
- func (i Int8) MarshalJSON() ([]byte, error)
- func (i Int8) MarshalYAML() ([]byte, error)
- func (i Int8) OrElse(v int8) int8
- func (i Int8) Present() bool
- func (i *Int8) Set(v int8)
- func (i *Int8) UnmarshalJSON(data []byte) error
- func (i *Int8) UnmarshalYAML(data []byte) error
- func (i Int8) Unwrap() int8
- type Rune
- func (r Rune) Get() (rune, error)
- func (r Rune) If(fn func(rune))
- func (r Rune) MarshalJSON() ([]byte, error)
- func (r Rune) MarshalYAML() ([]byte, error)
- func (r Rune) OrElse(v rune) rune
- func (r Rune) Present() bool
- func (r *Rune) Set(v rune)
- func (r *Rune) UnmarshalJSON(data []byte) error
- func (r *Rune) UnmarshalYAML(data []byte) error
- func (r Rune) Unwrap() rune
- type String
- func (s String) Get() (string, error)
- func (s String) If(fn func(string))
- func (s String) MarshalJSON() ([]byte, error)
- func (s String) MarshalYAML() ([]byte, error)
- func (s String) OrElse(v string) string
- func (s String) Present() bool
- func (s *String) Set(v string)
- func (s *String) UnmarshalJSON(data []byte) error
- func (s *String) UnmarshalYAML(data []byte) error
- func (s String) Unwrap() string
- type StringSlice
- func (s StringSlice) Get() ([]string, error)
- func (s StringSlice) If(fn func([]string))
- func (s StringSlice) MarshalJSON() ([]byte, error)
- func (s StringSlice) MarshalYAML() ([]byte, error)
- func (s StringSlice) OrElse(v []string) []string
- func (s StringSlice) Present() bool
- func (s *StringSlice) Set(v []string)
- func (s *StringSlice) UnmarshalJSON(data []byte) error
- func (s *StringSlice) UnmarshalYAML(data []byte) error
- func (s StringSlice) Unwrap() []string
- type Uint
- func (u Uint) Get() (uint, error)
- func (u Uint) If(fn func(uint))
- func (u Uint) MarshalJSON() ([]byte, error)
- func (u Uint) MarshalYAML() ([]byte, error)
- func (u Uint) OrElse(v uint) uint
- func (u Uint) Present() bool
- func (u *Uint) Set(v uint)
- func (u *Uint) UnmarshalJSON(data []byte) error
- func (u *Uint) UnmarshalYAML(data []byte) error
- func (u Uint) Unwrap() uint
- type Uint16
- func (u Uint16) Get() (uint16, error)
- func (u Uint16) If(fn func(uint16))
- func (u Uint16) MarshalJSON() ([]byte, error)
- func (u Uint16) MarshalYAML() ([]byte, error)
- func (u Uint16) OrElse(v uint16) uint16
- func (u Uint16) Present() bool
- func (u *Uint16) Set(v uint16)
- func (u *Uint16) UnmarshalJSON(data []byte) error
- func (u *Uint16) UnmarshalYAML(data []byte) error
- func (u Uint16) Unwrap() uint16
- type Uint32
- func (u Uint32) Get() (uint32, error)
- func (u Uint32) If(fn func(uint32))
- func (u Uint32) MarshalJSON() ([]byte, error)
- func (u Uint32) MarshalYAML() ([]byte, error)
- func (u Uint32) OrElse(v uint32) uint32
- func (u Uint32) Present() bool
- func (u *Uint32) Set(v uint32)
- func (u *Uint32) UnmarshalJSON(data []byte) error
- func (u *Uint32) UnmarshalYAML(data []byte) error
- func (u Uint32) Unwrap() uint32
- type Uint64
- func (u Uint64) Get() (uint64, error)
- func (u Uint64) If(fn func(uint64))
- func (u Uint64) MarshalJSON() ([]byte, error)
- func (u Uint64) MarshalYAML() ([]byte, error)
- func (u Uint64) OrElse(v uint64) uint64
- func (u Uint64) Present() bool
- func (u *Uint64) Set(v uint64)
- func (u *Uint64) UnmarshalJSON(data []byte) error
- func (u *Uint64) UnmarshalYAML(data []byte) error
- func (u Uint64) Unwrap() uint64
- type Uint8
- func (u Uint8) Get() (uint8, error)
- func (u Uint8) If(fn func(uint8))
- func (u Uint8) MarshalJSON() ([]byte, error)
- func (u Uint8) MarshalYAML() ([]byte, error)
- func (u Uint8) OrElse(v uint8) uint8
- func (u Uint8) Present() bool
- func (u *Uint8) Set(v uint8)
- func (u *Uint8) UnmarshalJSON(data []byte) error
- func (u *Uint8) UnmarshalYAML(data []byte) error
- func (u Uint8) Unwrap() uint8
- type Uintptr
- func (u Uintptr) Get() (uintptr, error)
- func (u Uintptr) If(fn func(uintptr))
- func (u Uintptr) MarshalJSON() ([]byte, error)
- func (u Uintptr) MarshalYAML() ([]byte, error)
- func (u Uintptr) OrElse(v uintptr) uintptr
- func (u Uintptr) Present() bool
- func (u *Uintptr) Set(v uintptr)
- func (u *Uintptr) UnmarshalJSON(data []byte) error
- func (u *Uintptr) UnmarshalYAML(data []byte) error
- func (u Uintptr) Unwrap() uintptr
Examples ¶
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 is an optional bool.
func (Bool) MarshalJSON ¶ added in v0.4.0
func (Bool) MarshalYAML ¶ added in v0.6.1
func (*Bool) UnmarshalJSON ¶ added in v0.4.0
func (*Bool) UnmarshalYAML ¶ added in v0.6.1
type Byte ¶
type Byte struct {
// contains filtered or unexported fields
}
Byte is an optional byte.
func (Byte) MarshalJSON ¶ added in v0.4.0
func (Byte) MarshalYAML ¶ added in v0.6.1
func (*Byte) UnmarshalJSON ¶ added in v0.4.0
func (*Byte) UnmarshalYAML ¶ added in v0.6.1
type Complex128 ¶
type Complex128 struct {
// contains filtered or unexported fields
}
Complex128 is an optional complex128.
func NewComplex128 ¶ added in v0.3.0
func NewComplex128(v complex128) Complex128
NewComplex128 creates an optional.Complex128 from a complex128.
func (Complex128) Get ¶
func (c Complex128) Get() (complex128, error)
Get returns the complex128 value or an error if not present.
func (Complex128) If ¶ added in v0.2.0
func (c Complex128) If(fn func(complex128))
If calls the function f with the value if the value is present.
func (Complex128) MarshalJSON ¶ added in v0.4.0
func (c Complex128) MarshalJSON() ([]byte, error)
func (Complex128) MarshalYAML ¶ added in v0.6.1
func (c Complex128) MarshalYAML() ([]byte, error)
func (Complex128) OrElse ¶
func (c Complex128) OrElse(v complex128) complex128
OrElse returns the complex128 value or a default value if the value is not present.
func (Complex128) Present ¶
func (c Complex128) Present() bool
Present returns whether or not the value is present.
func (*Complex128) UnmarshalJSON ¶ added in v0.4.0
func (c *Complex128) UnmarshalJSON(data []byte) error
func (*Complex128) UnmarshalYAML ¶ added in v0.6.1
func (c *Complex128) UnmarshalYAML(data []byte) error
func (Complex128) Unwrap ¶ added in v0.6.2
func (c Complex128) Unwrap() complex128
Unwrap returns the complex128 value or an error if not present.
type Complex64 ¶
type Complex64 struct {
// contains filtered or unexported fields
}
Complex64 is an optional complex64.
func NewComplex64 ¶ added in v0.3.0
NewComplex64 creates an optional.Complex64 from a complex64.
func (Complex64) If ¶ added in v0.2.0
If calls the function f with the value if the value is present.
func (Complex64) MarshalJSON ¶ added in v0.4.0
func (Complex64) MarshalYAML ¶ added in v0.6.1
func (Complex64) OrElse ¶
OrElse returns the complex64 value or a default value if the value is not present.
func (*Complex64) UnmarshalJSON ¶ added in v0.4.0
func (*Complex64) UnmarshalYAML ¶ added in v0.6.1
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an optional error.
func (Error) MarshalJSON ¶ added in v0.4.0
func (Error) MarshalYAML ¶ added in v0.6.1
func (Error) OrElse ¶
OrElse returns the error value or a default value if the value is not present.
func (*Error) UnmarshalJSON ¶ added in v0.4.0
func (*Error) UnmarshalYAML ¶ added in v0.6.1
type Float32 ¶
type Float32 struct {
// contains filtered or unexported fields
}
Float32 is an optional float32.
func NewFloat32 ¶ added in v0.3.0
NewFloat32 creates an optional.Float32 from a float32.
func (Float32) MarshalJSON ¶ added in v0.4.0
func (Float32) MarshalYAML ¶ added in v0.6.1
func (Float32) OrElse ¶
OrElse returns the float32 value or a default value if the value is not present.
func (*Float32) UnmarshalJSON ¶ added in v0.4.0
func (*Float32) UnmarshalYAML ¶ added in v0.6.1
type Float64 ¶
type Float64 struct {
// contains filtered or unexported fields
}
Float64 is an optional float64.
func NewFloat64 ¶ added in v0.3.0
NewFloat64 creates an optional.Float64 from a float64.
func (Float64) MarshalJSON ¶ added in v0.4.0
func (Float64) MarshalYAML ¶ added in v0.6.1
func (Float64) OrElse ¶
OrElse returns the float64 value or a default value if the value is not present.
func (*Float64) UnmarshalJSON ¶ added in v0.4.0
func (*Float64) UnmarshalYAML ¶ added in v0.6.1
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int is an optional int.
func (Int) MarshalJSON ¶ added in v0.4.0
func (Int) MarshalYAML ¶ added in v0.6.1
func (*Int) UnmarshalJSON ¶ added in v0.4.0
func (*Int) UnmarshalYAML ¶ added in v0.6.1
type Int16 ¶
type Int16 struct {
// contains filtered or unexported fields
}
Int16 is an optional int16.
func (Int16) MarshalJSON ¶ added in v0.4.0
func (Int16) MarshalYAML ¶ added in v0.6.1
func (Int16) OrElse ¶
OrElse returns the int16 value or a default value if the value is not present.
func (*Int16) UnmarshalJSON ¶ added in v0.4.0
func (*Int16) UnmarshalYAML ¶ added in v0.6.1
type Int32 ¶
type Int32 struct {
// contains filtered or unexported fields
}
Int32 is an optional int32.
func (Int32) MarshalJSON ¶ added in v0.4.0
func (Int32) MarshalYAML ¶ added in v0.6.1
func (Int32) OrElse ¶
OrElse returns the int32 value or a default value if the value is not present.
func (*Int32) UnmarshalJSON ¶ added in v0.4.0
func (*Int32) UnmarshalYAML ¶ added in v0.6.1
type Int64 ¶
type Int64 struct {
// contains filtered or unexported fields
}
Int64 is an optional int64.
func (Int64) MarshalJSON ¶ added in v0.4.0
func (Int64) MarshalYAML ¶ added in v0.6.1
func (Int64) OrElse ¶
OrElse returns the int64 value or a default value if the value is not present.
func (*Int64) UnmarshalJSON ¶ added in v0.4.0
func (*Int64) UnmarshalYAML ¶ added in v0.6.1
type Int8 ¶
type Int8 struct {
// contains filtered or unexported fields
}
Int8 is an optional int8.
func (Int8) MarshalJSON ¶ added in v0.4.0
func (Int8) MarshalYAML ¶ added in v0.6.1
func (*Int8) UnmarshalJSON ¶ added in v0.4.0
func (*Int8) UnmarshalYAML ¶ added in v0.6.1
type Rune ¶
type Rune struct {
// contains filtered or unexported fields
}
Rune is an optional rune.
func (Rune) MarshalJSON ¶ added in v0.4.0
func (Rune) MarshalYAML ¶ added in v0.6.1
func (*Rune) UnmarshalJSON ¶ added in v0.4.0
func (*Rune) UnmarshalYAML ¶ added in v0.6.1
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is an optional string.
func (String) MarshalJSON ¶ added in v0.4.0
func (String) MarshalYAML ¶ added in v0.6.1
func (String) OrElse ¶
OrElse returns the string value or a default value if the value is not present.
func (*String) UnmarshalJSON ¶ added in v0.4.0
func (*String) UnmarshalYAML ¶ added in v0.6.1
type StringSlice ¶ added in v0.6.1
type StringSlice struct {
// contains filtered or unexported fields
}
StringSlice is an optional []string.
func NewStringSlice ¶ added in v0.6.1
func NewStringSlice(v []string) StringSlice
NewStringSlice creates an optional.StringSlice from a []string.
func (StringSlice) Get ¶ added in v0.6.1
func (s StringSlice) Get() ([]string, error)
Get returns the []string value or an error if not present.
func (StringSlice) If ¶ added in v0.6.1
func (s StringSlice) If(fn func([]string))
If calls the function f with the value if the value is present.
func (StringSlice) MarshalJSON ¶ added in v0.6.1
func (s StringSlice) MarshalJSON() ([]byte, error)
func (StringSlice) MarshalYAML ¶ added in v0.6.1
func (s StringSlice) MarshalYAML() ([]byte, error)
func (StringSlice) OrElse ¶ added in v0.6.1
func (s StringSlice) OrElse(v []string) []string
OrElse returns the []string value or a default value if the value is not present.
func (StringSlice) Present ¶ added in v0.6.1
func (s StringSlice) Present() bool
Present returns whether or not the value is present.
func (*StringSlice) Set ¶ added in v0.6.1
func (s *StringSlice) Set(v []string)
Set sets the []string value.
func (*StringSlice) UnmarshalJSON ¶ added in v0.6.1
func (s *StringSlice) UnmarshalJSON(data []byte) error
func (*StringSlice) UnmarshalYAML ¶ added in v0.6.1
func (s *StringSlice) UnmarshalYAML(data []byte) error
func (StringSlice) Unwrap ¶ added in v0.6.2
func (s StringSlice) Unwrap() []string
Unwrap returns the []string value or an error if not present.
type Uint ¶
type Uint struct {
// contains filtered or unexported fields
}
Uint is an optional uint.
func (Uint) MarshalJSON ¶ added in v0.4.0
func (Uint) MarshalYAML ¶ added in v0.6.1
func (*Uint) UnmarshalJSON ¶ added in v0.4.0
func (*Uint) UnmarshalYAML ¶ added in v0.6.1
type Uint16 ¶
type Uint16 struct {
// contains filtered or unexported fields
}
Uint16 is an optional uint16.
func (Uint16) MarshalJSON ¶ added in v0.4.0
func (Uint16) MarshalYAML ¶ added in v0.6.1
func (Uint16) OrElse ¶
OrElse returns the uint16 value or a default value if the value is not present.
func (*Uint16) UnmarshalJSON ¶ added in v0.4.0
func (*Uint16) UnmarshalYAML ¶ added in v0.6.1
type Uint32 ¶
type Uint32 struct {
// contains filtered or unexported fields
}
Uint32 is an optional uint32.
func (Uint32) MarshalJSON ¶ added in v0.4.0
func (Uint32) MarshalYAML ¶ added in v0.6.1
func (Uint32) OrElse ¶
OrElse returns the uint32 value or a default value if the value is not present.
func (*Uint32) UnmarshalJSON ¶ added in v0.4.0
func (*Uint32) UnmarshalYAML ¶ added in v0.6.1
type Uint64 ¶
type Uint64 struct {
// contains filtered or unexported fields
}
Uint64 is an optional uint64.
func (Uint64) MarshalJSON ¶ added in v0.4.0
func (Uint64) MarshalYAML ¶ added in v0.6.1
func (Uint64) OrElse ¶
OrElse returns the uint64 value or a default value if the value is not present.
func (*Uint64) UnmarshalJSON ¶ added in v0.4.0
func (*Uint64) UnmarshalYAML ¶ added in v0.6.1
type Uint8 ¶
type Uint8 struct {
// contains filtered or unexported fields
}
Uint8 is an optional uint8.
func (Uint8) MarshalJSON ¶ added in v0.4.0
func (Uint8) MarshalYAML ¶ added in v0.6.1
func (Uint8) OrElse ¶
OrElse returns the uint8 value or a default value if the value is not present.
func (*Uint8) UnmarshalJSON ¶ added in v0.4.0
func (*Uint8) UnmarshalYAML ¶ added in v0.6.1
type Uintptr ¶
type Uintptr struct {
// contains filtered or unexported fields
}
Uintptr is an optional uintptr.
func NewUintptr ¶ added in v0.3.0
NewUintptr creates an optional.Uintptr from a uintptr.
func (Uintptr) MarshalJSON ¶ added in v0.4.0
func (Uintptr) MarshalYAML ¶ added in v0.6.1
func (Uintptr) OrElse ¶
OrElse returns the uintptr value or a default value if the value is not present.
func (*Uintptr) UnmarshalJSON ¶ added in v0.4.0
func (*Uintptr) UnmarshalYAML ¶ added in v0.6.1
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
optional
Optional is a tool that generates 'optional' type wrappers around a given type T. Typically this process would be run using go generate, like this: //go:generate optional -type=Foo running this command optional -type=Foo in the same directory will create the file optional_foo.go containing a definition of type OptionalFoo struct { ...
|
Optional is a tool that generates 'optional' type wrappers around a given type T. Typically this process would be run using go generate, like this: //go:generate optional -type=Foo running this command optional -type=Foo in the same directory will create the file optional_foo.go containing a definition of type OptionalFoo struct { ... |