Documentation ¶
Overview ¶
Package dynamic contains dynamic types that can be various values
Index ¶
- Variables
- type Bool
- func (b *Bool) Bool() (bool, bool)
- func (b *Bool) Clear()
- func (b Bool) Equal(value interface{}) bool
- func (b Bool) HasValue() bool
- func (b *Bool) IsFalse() bool
- func (b *Bool) IsNil() bool
- func (b *Bool) IsNull() bool
- func (b *Bool) IsTrue() bool
- func (b Bool) MarshalJSON() ([]byte, error)
- func (b *Bool) Parse(str string) error
- func (b *Bool) Set(value interface{}) error
- func (b *Bool) SetValue(v bool)
- func (b *Bool) String() string
- func (b *Bool) UnmarshalJSON(data []byte) error
- func (b Bool) Value() interface{}
- type BoolOrString
- func (bs *BoolOrString) Bool() (value bool, isBool bool)
- func (bs *BoolOrString) Dereference() BoolOrString
- func (bs *BoolOrString) EncodeToEmptyString() *BoolOrString
- func (bs *BoolOrString) EncodeToNull() *BoolOrString
- func (bs *BoolOrString) IsBool() bool
- func (bs *BoolOrString) IsEmpty() bool
- func (bs *BoolOrString) IsNil() bool
- func (bs BoolOrString) MarshalJSON() ([]byte, error)
- func (bs *BoolOrString) Reference() *BoolOrString
- func (bs *BoolOrString) Set(value interface{}) error
- func (bs BoolOrString) String() string
- func (bs *BoolOrString) UnmarshalJSON(data []byte) error
- type JSON
- func (d JSON) ContainsEscapeRune() bool
- func (d JSON) Equal(data []byte) bool
- func (d JSON) IsArray() bool
- func (d JSON) IsBool() bool
- func (d JSON) IsEmptyArray() bool
- func (d JSON) IsEmptyObject() bool
- func (d JSON) IsFalse() bool
- func (d JSON) IsNull() bool
- func (d JSON) IsNumber() bool
- func (d JSON) IsObject() bool
- func (d JSON) IsString() bool
- func (d JSON) IsTrue() bool
- func (d JSON) Len() int
- func (d JSON) MarshalJSON() ([]byte, error)
- func (d *JSON) UnmarshalJSON(data []byte) error
- func (d JSON) UnquotedString() string
- type JSONObject
- type Map
- type Number
- func (n Number) Bytes() []byte
- func (n *Number) Clear()
- func (n Number) Float32() (float32, bool)
- func (n Number) Float64() (float64, bool)
- func (n Number) HasValue() bool
- func (n Number) Int() (int, bool)
- func (n Number) Int16() (int16, bool)
- func (n Number) Int32() (int32, bool)
- func (n Number) Int64() (int64, bool)
- func (n Number) Int8() (int8, bool)
- func (n Number) IsNil() bool
- func (n Number) MarshalJSON() ([]byte, error)
- func (n *Number) Parse(s string) error
- func (n *Number) Set(value interface{}) error
- func (n Number) String() string
- func (n Number) Uint() (uint, bool)
- func (n Number) Uint16() (uint16, bool)
- func (n Number) Uint32() (uint32, bool)
- func (n Number) Uint64() (uint64, bool)
- func (n Number) Uint8() (uint8, bool)
- func (n *Number) UnmarshalJSON(data []byte) error
- func (n *Number) Value() interface{}
- type String
- func (s *String) Bool() (bool, error)
- func (s *String) Bytes() []byte
- func (s *String) Clear()
- func (s *String) Compare(value interface{}) (int, error)
- func (s *String) Complex() (complex128, error)
- func (s *String) Complex128() (complex128, error)
- func (s *String) Complex64() (complex64, error)
- func (s *String) Contains(value interface{}) (bool, error)
- func (s *String) ContainsAny(value interface{}) (bool, error)
- func (s *String) ContainsRune(r rune) bool
- func (s *String) Copy() (*String, error)
- func (s *String) Count(value interface{}) int
- func (s *String) Dereference() String
- func (s *String) Duration() (time.Duration, error)
- func (s *String) EncodeNilToEmptyString()
- func (s *String) EncodeNilToNull()
- func (s *String) Equal(value interface{}) (bool, error)
- func (s *String) EqualFold(value interface{}) (bool, error)
- func (s *String) Fields() ([]string, error)
- func (s *String) FieldsFunc(f func(rune) bool) []string
- func (s *String) Float() (float64, error)
- func (s *String) Float32() (float32, error)
- func (s *String) Float64() (float64, error)
- func (s *String) HasPrefix(value interface{}, timeLayouts ...string) (bool, error)
- func (s *String) HasSuffix(value interface{}) (bool, error)
- func (s *String) HasValue() bool
- func (s *String) Index(value interface{}) (int, error)
- func (s *String) IndexAny(value interface{}) (int, error)
- func (s *String) IndexByte(c byte) int
- func (s *String) IndexFunc(fn func(r rune) bool) int
- func (s *String) IndexRune(r rune) int
- func (s *String) Int() (int64, error)
- func (s *String) IsEmpty() bool
- func (s *String) IsNil() bool
- func (s *String) IsNull() bool
- func (s *String) LastIndex(value interface{}) (int, error)
- func (s *String) LastIndexByte(c byte) int
- func (s *String) LastIndexFunc(fn func(r rune) bool) int
- func (s *String) Len() int
- func (s *String) Map(mapping func(rune) rune) (*String, error)
- func (s String) MarshalJSON() ([]byte, error)
- func (s *String) NewReader() *strings.Reader
- func (s *String) Reference() *String
- func (s *String) Replace(old interface{}, new interface{}, n int) (*String, error)
- func (s *String) ReplaceAll(old interface{}, new interface{}) (*String, error)
- func (s *String) Set(value interface{}, timeLayout ...string) error
- func (s *String) Split(sep interface{}) ([]string, error)
- func (s *String) SplitAfter(sep interface{}) ([]string, error)
- func (s *String) SplitAfterN(sep interface{}, n int) ([]string, error)
- func (s *String) SplitN(sep interface{}, n int) ([]string, error)
- func (s *String) String() string
- func (s *String) Time(layout string) (time.Time, error)
- func (s *String) Title() (*String, error)
- func (s *String) ToLower() (*String, error)
- func (s *String) ToLowerSpecial(c unicode.SpecialCase) (*String, error)
- func (s *String) ToTitle() (*String, error)
- func (s *String) ToTitleSpecial(c unicode.SpecialCase) (*String, error)
- func (s *String) ToUpper() (*String, error)
- func (s *String) ToUpperSpecial(c unicode.SpecialCase) (*String, error)
- func (s *String) ToValidUTF8(replacement interface{}) (*String, error)
- func (s *String) Uint() (uint64, error)
- func (s *String) UnmarshalJSON(data []byte) error
- func (s *String) Value() interface{}
- type StringNumberBoolOrTime
- func (snbt *StringNumberBoolOrTime) Bool() (bool, bool)
- func (snbt *StringNumberBoolOrTime) Clear()
- func (snbt *StringNumberBoolOrTime) Float32() (float32, bool)
- func (snbt *StringNumberBoolOrTime) Float64() (float64, bool)
- func (snbt StringNumberBoolOrTime) Format(layout string) string
- func (snbt *StringNumberBoolOrTime) Int() (int, bool)
- func (snbt *StringNumberBoolOrTime) Int16() (int16, bool)
- func (snbt *StringNumberBoolOrTime) Int32() (int32, bool)
- func (snbt *StringNumberBoolOrTime) Int64() (int64, bool)
- func (snbt *StringNumberBoolOrTime) Int8() (int8, bool)
- func (snbt *StringNumberBoolOrTime) IsBool() bool
- func (snbt *StringNumberBoolOrTime) IsEmptyString() bool
- func (snbt StringNumberBoolOrTime) IsNil() bool
- func (snbt *StringNumberBoolOrTime) IsNumber() bool
- func (snbt StringNumberBoolOrTime) IsString() bool
- func (snbt *StringNumberBoolOrTime) IsTime(layout ...string) bool
- func (snbt StringNumberBoolOrTime) MarshalJSON() ([]byte, error)
- func (snbt *StringNumberBoolOrTime) Number() interface{}
- func (snbt *StringNumberBoolOrTime) Set(value interface{}) error
- func (snbt StringNumberBoolOrTime) String() string
- func (snbt *StringNumberBoolOrTime) Time(layout ...string) (time.Time, bool)
- func (snbt *StringNumberBoolOrTime) Uint() (uint, bool)
- func (snbt *StringNumberBoolOrTime) Uint16() (uint16, bool)
- func (snbt *StringNumberBoolOrTime) Uint32() (uint32, bool)
- func (snbt *StringNumberBoolOrTime) Uint64() (uint64, bool)
- func (snbt *StringNumberBoolOrTime) Uint8() (uint8, bool)
- func (snbt *StringNumberBoolOrTime) UnmarshalJSON(data []byte) error
- func (snbt StringNumberBoolOrTime) Value() interface{}
- type StringNumberOrTime
- func (snt *StringNumberOrTime) Clear()
- func (snt *StringNumberOrTime) Float32() (float32, bool)
- func (snt *StringNumberOrTime) Float64() (float64, bool)
- func (snt StringNumberOrTime) Format(layout string) string
- func (snt *StringNumberOrTime) Int() (int, bool)
- func (snt *StringNumberOrTime) Int16() (int16, bool)
- func (snt *StringNumberOrTime) Int32() (int32, bool)
- func (snt *StringNumberOrTime) Int64() (int64, bool)
- func (snt *StringNumberOrTime) Int8() (int8, bool)
- func (snt StringNumberOrTime) IsNil() bool
- func (snt *StringNumberOrTime) IsNilOrEmpty() bool
- func (snt *StringNumberOrTime) IsNilOrZero() bool
- func (snt *StringNumberOrTime) IsNumber() bool
- func (snt StringNumberOrTime) IsString() bool
- func (snt *StringNumberOrTime) IsTime(layout ...string) bool
- func (snt StringNumberOrTime) MarshalJSON() ([]byte, error)
- func (snt *StringNumberOrTime) Number() interface{}
- func (snt *StringNumberOrTime) Set(value interface{}) error
- func (snt StringNumberOrTime) String() string
- func (snt *StringNumberOrTime) Time(layout ...string) (time.Time, bool)
- func (snt *StringNumberOrTime) Uint() (uint, bool)
- func (snt *StringNumberOrTime) Uint16() (uint16, bool)
- func (snt *StringNumberOrTime) Uint32() (uint32, bool)
- func (snt *StringNumberOrTime) Uint64() (uint64, bool)
- func (snt *StringNumberOrTime) Uint8() (uint8, bool)
- func (snt *StringNumberOrTime) UnmarshalJSON(data []byte) error
- func (snt StringNumberOrTime) Value() interface{}
- type StringOrArrayOfStrings
- func (sas *StringOrArrayOfStrings) Add(v string)
- func (sas StringOrArrayOfStrings) GetIndex(i int) (string, error)
- func (sas StringOrArrayOfStrings) IndexOf(v string) int
- func (sas *StringOrArrayOfStrings) IsEmpty() bool
- func (sas *StringOrArrayOfStrings) IsNil() bool
- func (sas *StringOrArrayOfStrings) Iterate(fn func(string) error) error
- func (sas StringOrArrayOfStrings) MarshalJSON() ([]byte, error)
- func (sas *StringOrArrayOfStrings) RemoveIndex(i int) error
- func (sas *StringOrArrayOfStrings) Set(v interface{}) error
- func (sas *StringOrArrayOfStrings) UnmarshalJSON(data []byte) error
- type StringOrNumber
- func (sn *StringOrNumber) Bool() (bool, bool)
- func (sn *StringOrNumber) Clear()
- func (sn *StringOrNumber) Duration() (time.Duration, bool)
- func (sn *StringOrNumber) Float32() (float32, bool)
- func (sn *StringOrNumber) Float64() (float64, bool)
- func (sn *StringOrNumber) Int() (int, bool)
- func (sn *StringOrNumber) Int16() (int16, bool)
- func (sn *StringOrNumber) Int32() (int32, bool)
- func (sn *StringOrNumber) Int64() (int64, bool)
- func (sn *StringOrNumber) Int8() (int8, bool)
- func (sn *StringOrNumber) IsBool() bool
- func (sn *StringOrNumber) IsEmptyString() bool
- func (sn StringOrNumber) IsNil() bool
- func (sn *StringOrNumber) IsNumber() bool
- func (sn StringOrNumber) IsString() bool
- func (sn *StringOrNumber) IsTime(layout ...string) bool
- func (sn StringOrNumber) MarshalJSON() ([]byte, error)
- func (sn *StringOrNumber) Number() interface{}
- func (sn *StringOrNumber) Set(value interface{}) error
- func (sn StringOrNumber) String() string
- func (sn *StringOrNumber) Time(layout ...string) (time.Time, bool)
- func (sn *StringOrNumber) Uint() (uint, bool)
- func (sn *StringOrNumber) Uint16() (uint16, bool)
- func (sn *StringOrNumber) Uint32() (uint32, bool)
- func (sn *StringOrNumber) Uint64() (uint64, bool)
- func (sn *StringOrNumber) Uint8() (uint8, bool)
- func (sn *StringOrNumber) UnmarshalJSON(data []byte) error
- func (sn StringOrNumber) Value() interface{}
- type Time
- func (t *Time) Clear()
- func (t *Time) Format(layout string) string
- func (t Time) HasValue() bool
- func (t Time) IsNil() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t *Time) Parse(s string, layouts ...string) error
- func (t *Time) Set(value interface{}, layout ...string) error
- func (t *Time) SetFormat(str string)
- func (t Time) String() string
- func (t Time) Time() (time.Time, bool)
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) Value() interface{}
- Bugs
Constants ¶
This section is empty.
Variables ¶
var ( False = Bool{/* contains filtered or unexported fields */} True = Bool{/* contains filtered or unexported fields */} )
var ( ErrInvalidValue = errors.New("dynamic: invalid value") ErrInvalidType = errors.New("dynamic: invalid type") )
errors
var ( ErrIndexOutOfBounds = errors.New("index out of bounds") Done = errors.New("done") )
var DefaultTimeLayout = func() string { return DefaultTimeLayouts[0] }
var DefaultTimeLayouts = []string{time.RFC3339}
var Null = JSON("null")
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
func NewBool ¶
NewBool returns a new Bool value initialized to the first, if any, value passed in.
You can set Bool to any of the following:
bool, dynamic.Bool, *bool, *dynamic.Bool string, []byte, fmt.Stringer, *string nil
func NewBoolPtr ¶
NewBoolPtr returns a pointer to a new Bool
See NewBool for valid options, usage and warnings
func (Bool) MarshalJSON ¶
func (*Bool) UnmarshalJSON ¶
type BoolOrString ¶
type BoolOrString struct {
// contains filtered or unexported fields
}
BoolOrString is a dynamic type that is a string, bool, or nil. It stores the value as a string and decodes json into either a bool or a string
func NewBoolOrString ¶
func NewBoolOrString(value interface{}) (BoolOrString, error)
NewBoolOrString returns a new BoolOrString
Valid value types
string, []byte, dynamic.String, dynamic.Bool, fmt.Stringer, []string, *string, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
func NewBoolOrStringPtr ¶
func NewBoolOrStringPtr(value interface{}) (*BoolOrString, error)
NewBoolOrStringPtr returns a pointer to a new BoolOrString
Valid value types:
string, []byte, dynamic.String, dynamic.Bool, fmt.Stringer, []string, *string, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
func (*BoolOrString) Bool ¶
func (bs *BoolOrString) Bool() (value bool, isBool bool)
func (*BoolOrString) Dereference ¶
func (bs *BoolOrString) Dereference() BoolOrString
func (*BoolOrString) EncodeToEmptyString ¶
func (bs *BoolOrString) EncodeToEmptyString() *BoolOrString
func (*BoolOrString) EncodeToNull ¶
func (bs *BoolOrString) EncodeToNull() *BoolOrString
func (*BoolOrString) IsBool ¶
func (bs *BoolOrString) IsBool() bool
func (*BoolOrString) IsEmpty ¶
func (bs *BoolOrString) IsEmpty() bool
func (*BoolOrString) IsNil ¶
func (bs *BoolOrString) IsNil() bool
func (BoolOrString) MarshalJSON ¶
func (bs BoolOrString) MarshalJSON() ([]byte, error)
func (*BoolOrString) Reference ¶
func (bs *BoolOrString) Reference() *BoolOrString
func (*BoolOrString) Set ¶
func (bs *BoolOrString) Set(value interface{}) error
Set sets the BoolOrString's value
Valid value types:
You can set String to any of the following:
string, []byte, dynamic.String, dynamic.Bool, fmt.Stringer, []string, *string, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
func (BoolOrString) String ¶
func (bs BoolOrString) String() string
func (*BoolOrString) UnmarshalJSON ¶
func (bs *BoolOrString) UnmarshalJSON(data []byte) error
type JSON ¶
type JSON []byte
func (JSON) ContainsEscapeRune ¶
ContainsEscapeRune reports whether the string value of d contains "\" It returns false if d is not a quoted string.
func (JSON) IsArray ¶
IsArray reports whether the data is a json array. It does not check whether the json is malformed.
func (JSON) IsBool ¶
IsBool reports true if data appears to be a json boolean value. It is possible that it will report false positives of malformed json.
IsBool does not parse strings
func (JSON) IsEmptyArray ¶
func (JSON) IsEmptyObject ¶
func (JSON) IsFalse ¶
IsFalse reports true if data appears to be a json boolean value of false. It is possible that it will report false positives of malformed json as it only checks the first character and length.
IsFalse does not parse strings
func (JSON) IsTrue ¶
IsTrue reports true if data appears to be a json boolean value of true. It is possible that it will report false positives of malformed json as it only checks the first character and length.
IsTrue does not parse strings
func (JSON) MarshalJSON ¶
func (*JSON) UnmarshalJSON ¶
func (JSON) UnquotedString ¶
UnquotedString trims double quotes from the bytes. It does not parse for escaped characters
type JSONObject ¶
func (JSONObject) MarshalJSON ¶
func (obj JSONObject) MarshalJSON() ([]byte, error)
func (*JSONObject) UnmarshalJSON ¶
func (obj *JSONObject) UnmarshalJSON(data []byte) error
type Number ¶
type Number struct {
// contains filtered or unexported fields
}
func NewNumber ¶
NewNumber returns a new Number set to the first, if any, parameters.
You can set String to any of the following:
string, *string, json.Number, fmt.Stringer, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, *float64, *float32
func NewNumberPtr ¶
NewNumberPtr returns a pointer to a new Number. See NewNumber for information & warnings.
func (Number) MarshalJSON ¶
func (*Number) UnmarshalJSON ¶
type String ¶
type String struct {
// contains filtered or unexported fields
}
func NewString ¶
NewString returns a new String. Only the first parameter passed in is considered.
String can be set to any of the following:
string, []byte, dynamic.String, fmt.Stringer, []string, *string, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
func NewStringPtr ¶
NewStringPtr returns a pointer to a new String
See NewString for information on valid values and usage
func (*String) Compare ¶
Compare returns an integer comparing two strings lexicographically.
The result will be 0 if s==value, -1 if s < value, and +1 if s > value.
func (*String) Complex ¶
func (s *String) Complex() (complex128, error)
func (*String) Complex128 ¶
func (s *String) Complex128() (complex128, error)
func (*String) ContainsAny ¶
ContainsAny reports whether any Unicode code points in chars are within s.
func (*String) ContainsRune ¶
func (*String) Count ¶
Count counts the number of non-overlapping instances of substr in s.
If substr is an empty string, Count returns 1 + the number of Unicode code points in s.
func (*String) Dereference ¶
func (*String) EncodeNilToEmptyString ¶
func (s *String) EncodeNilToEmptyString()
func (*String) EncodeNilToNull ¶
func (s *String) EncodeNilToNull()
func (*String) Equal ¶
Equal reports whether the formatted value is equal to the underlying value of *String s.
func (*String) EqualFold ¶
EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, which is a more general form of case-insensitivity.
func (*String) Fields ¶
Fields splits the string s around each instance of one or more consecutive white space characters, as defined by unicode.IsSpace, returning a slice of substrings of s or an empty slice if s contains only white space.
func (*String) Index ¶
Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.
func (*String) IndexAny ¶
IndexAny returns the index of the first instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
func (*String) IndexByte ¶
IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
func (*String) IndexFunc ¶
IndexFunc returns the index into s of the first Unicode code point satisfying f(c), or -1 if none do.
func (*String) IndexRune ¶
IndexRune returns the index of the first instance of the Unicode code point r, or -1 if rune is not present in s. If r is utf8.RuneError, it returns the first instance of any invalid UTF-8 byte sequence.
func (*String) LastIndex ¶
LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.
func (*String) LastIndexByte ¶
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
func (*String) LastIndexFunc ¶
LastIndexFunc returns the index into s of the last Unicode code point satisfying f(c), or -1 if none do.
func (*String) Map ¶
Map returns a copy of *String s with all its characters modified according to the mapping function. If mapping returns a negative value, the character is dropped from the string with no replacement.
func (String) MarshalJSON ¶
func (*String) Replace ¶
Replace returns a copy of the string s with the first n non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string. If n < 0, there is no limit on the number of replacements.
func (*String) ReplaceAll ¶
ReplaceAll returns a copy of the string s with all non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string.
func (*String) Split ¶
Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.
If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.
If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.
It is equivalent to SplitN with a count of -1.
func (*String) SplitAfter ¶
SplitAfter slices s into all substrings after each instance of sep and returns a slice of those substrings.
If s does not contain sep and sep is not empty, SplitAfter returns a slice of length 1 whose only element is s.
If sep is empty, SplitAfter splits after each UTF-8 sequence. If both s and sep are empty, SplitAfter returns an empty slice.
It is equivalent to SplitAfterN with a count of -1.
func (*String) SplitN ¶
SplitN slices s into substrings separated by sep and returns a slice of the substrings between those separators.
The count determines the number of substrings to return:
func (*String) Title ¶
Title returns a copy of the *String s with all Unicode letters that begin words mapped to their Unicode title case.
BUG(rsc): The rule Title uses for word boundaries does not handle Unicode punctuation properly.
func (*String) ToLower ¶
ToLower returns a new *String with all Unicode letters mapped to their lower case.
func (*String) ToLowerSpecial ¶
func (s *String) ToLowerSpecial(c unicode.SpecialCase) (*String, error)
ToLowerSpecial returns a copy of the *String s with all Unicode letters mapped to their lower case using the case mapping specified by c.
func (*String) ToTitle ¶
ToTitle returns a copy of the *String s with all Unicode letters mapped to their Unicode title case.
func (*String) ToTitleSpecial ¶
func (s *String) ToTitleSpecial(c unicode.SpecialCase) (*String, error)
ToTitleSpecial returns a copy of the *String s with all Unicode letters mapped to their Unicode title case, giving priority to the special casing rules.
func (*String) ToUpperSpecial ¶
func (s *String) ToUpperSpecial(c unicode.SpecialCase) (*String, error)
ToUpperSpecial returns a copy of the *String s with all Unicode letters mapped to their upper case using the case mapping specified by c.
func (*String) ToValidUTF8 ¶
ToValidUTF8 returns a copy of the string s with each run of invalid UTF-8 byte sequences replaced by the replacement string, which may be empty.
func (*String) UnmarshalJSON ¶
type StringNumberBoolOrTime ¶
type StringNumberBoolOrTime struct {
// contains filtered or unexported fields
}
func NewStringNumberBoolOrTime ¶
func NewStringNumberBoolOrTime(value interface{}) (StringNumberBoolOrTime, error)
NewStringNumberBoolOrTime returns a new StringNumberBoolOrTime set to the first value, if any.
String can be set to any of the following:
string, []byte, dynamic.String, fmt.Stringer, []string, *string, time.Time, *time.Time, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
func NewStringNumberBoolOrTimePtr ¶
func NewStringNumberBoolOrTimePtr(value interface{}) (*StringNumberBoolOrTime, error)
func (*StringNumberBoolOrTime) Bool ¶
func (snbt *StringNumberBoolOrTime) Bool() (bool, bool)
func (*StringNumberBoolOrTime) Clear ¶
func (snbt *StringNumberBoolOrTime) Clear()
Clear sets the value of StringNumberBoolOrTime to nil
func (*StringNumberBoolOrTime) Float32 ¶
func (snbt *StringNumberBoolOrTime) Float32() (float32, bool)
func (*StringNumberBoolOrTime) Float64 ¶
func (snbt *StringNumberBoolOrTime) Float64() (float64, bool)
func (StringNumberBoolOrTime) Format ¶
func (snbt StringNumberBoolOrTime) Format(layout string) string
Format is used only with time. If the value of StringNumberBoolOrTime is anything else, the string representation will be returned
func (*StringNumberBoolOrTime) Int ¶
func (snbt *StringNumberBoolOrTime) Int() (int, bool)
func (*StringNumberBoolOrTime) Int16 ¶
func (snbt *StringNumberBoolOrTime) Int16() (int16, bool)
func (*StringNumberBoolOrTime) Int32 ¶
func (snbt *StringNumberBoolOrTime) Int32() (int32, bool)
func (*StringNumberBoolOrTime) Int64 ¶
func (snbt *StringNumberBoolOrTime) Int64() (int64, bool)
func (*StringNumberBoolOrTime) Int8 ¶
func (snbt *StringNumberBoolOrTime) Int8() (int8, bool)
func (*StringNumberBoolOrTime) IsBool ¶
func (snbt *StringNumberBoolOrTime) IsBool() bool
IsBool reports whether the value is a boolean or a string representation of a boolean.
The underlying type of StringNumberBoolOrTime is altered from a string to a bool if the value is successfully parsed.
func (*StringNumberBoolOrTime) IsEmptyString ¶
func (snbt *StringNumberBoolOrTime) IsEmptyString() bool
IsEmptyString returns true if snbt is nil or an empty string
func (StringNumberBoolOrTime) IsNil ¶
func (snbt StringNumberBoolOrTime) IsNil() bool
func (*StringNumberBoolOrTime) IsNumber ¶
func (snbt *StringNumberBoolOrTime) IsNumber() bool
func (StringNumberBoolOrTime) IsString ¶
func (snbt StringNumberBoolOrTime) IsString() bool
IsString reports whether the value is a string
Note: if you've used any of the other type checks before this that reported true, the string may have been cast and is no longer a string.
func (*StringNumberBoolOrTime) IsTime ¶
func (snbt *StringNumberBoolOrTime) IsTime(layout ...string) bool
func (StringNumberBoolOrTime) MarshalJSON ¶
func (snbt StringNumberBoolOrTime) MarshalJSON() ([]byte, error)
func (*StringNumberBoolOrTime) Number ¶
func (snbt *StringNumberBoolOrTime) Number() interface{}
Number returns the underlying value of Number. It could be: int64, uint64, float64, or nil. If you need specific types, use their corresponding methods.
func (*StringNumberBoolOrTime) Set ¶
func (snbt *StringNumberBoolOrTime) Set(value interface{}) error
Set sets the value of StringNumberBoolOrTime to value. The type of value can be any of the following:
time.Time, *time.Time string, *string json.Number, *json.Number float64, *float64, float32, *float32 int, *int, int64, *int64, int32, *int32, int16, *int16, int8, *int8 uint, *uint, uint64, *uint64, uint32, *uint32, uint16, *uint16, uint8, *uint8 bool, *bool fmt.Stringer nil
All pointer values are dereferenced.
Set returns an error if value is not one of the aforementioned types
func (StringNumberBoolOrTime) String ¶
func (snbt StringNumberBoolOrTime) String() string
func (*StringNumberBoolOrTime) Time ¶
func (snbt *StringNumberBoolOrTime) Time(layout ...string) (time.Time, bool)
Time returns the Time value and true. If the original value is a string, Time attempts to parse it with the DefaultTimeLayouts or the provided layouts
func (*StringNumberBoolOrTime) Uint ¶
func (snbt *StringNumberBoolOrTime) Uint() (uint, bool)
func (*StringNumberBoolOrTime) Uint16 ¶
func (snbt *StringNumberBoolOrTime) Uint16() (uint16, bool)
func (*StringNumberBoolOrTime) Uint32 ¶
func (snbt *StringNumberBoolOrTime) Uint32() (uint32, bool)
func (*StringNumberBoolOrTime) Uint64 ¶
func (snbt *StringNumberBoolOrTime) Uint64() (uint64, bool)
func (*StringNumberBoolOrTime) Uint8 ¶
func (snbt *StringNumberBoolOrTime) Uint8() (uint8, bool)
func (*StringNumberBoolOrTime) UnmarshalJSON ¶
func (snbt *StringNumberBoolOrTime) UnmarshalJSON(data []byte) error
func (StringNumberBoolOrTime) Value ¶
func (snbt StringNumberBoolOrTime) Value() interface{}
type StringNumberOrTime ¶
type StringNumberOrTime struct {
// contains filtered or unexported fields
}
func NewStringNumberOrTime ¶
func NewStringNumberOrTime(value interface{}) (StringNumberOrTime, error)
NewStringNumberOrTime returns a new StringNumberOrTime set to the first value, if any.
You can set String to any of the following:
string, []byte, dynamic.String, fmt.Stringer, []string, *string, time.Time, *time.Time, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
If you need type checking, use Set
func NewStringNumberOrTimePtr ¶
func NewStringNumberOrTimePtr(value interface{}) (*StringNumberOrTime, error)
NewStringNumberOrTimePtr returns a pointer to a new NewStringNumberOrTimePtr
See NewNewStringNumberOrTime for info & warnings
func (*StringNumberOrTime) Clear ¶
func (snt *StringNumberOrTime) Clear()
Clear sets the value of StringNumberOrTime to nil
func (*StringNumberOrTime) Float32 ¶
func (snt *StringNumberOrTime) Float32() (float32, bool)
func (*StringNumberOrTime) Float64 ¶
func (snt *StringNumberOrTime) Float64() (float64, bool)
func (StringNumberOrTime) Format ¶
func (snt StringNumberOrTime) Format(layout string) string
Format is used only with time. If the value of StringNumberOrTime is anything else, the string representation will be returned
func (*StringNumberOrTime) Int ¶
func (snt *StringNumberOrTime) Int() (int, bool)
func (*StringNumberOrTime) Int16 ¶
func (snt *StringNumberOrTime) Int16() (int16, bool)
func (*StringNumberOrTime) Int32 ¶
func (snt *StringNumberOrTime) Int32() (int32, bool)
func (*StringNumberOrTime) Int64 ¶
func (snt *StringNumberOrTime) Int64() (int64, bool)
func (*StringNumberOrTime) Int8 ¶
func (snt *StringNumberOrTime) Int8() (int8, bool)
func (StringNumberOrTime) IsNil ¶
func (snt StringNumberOrTime) IsNil() bool
func (*StringNumberOrTime) IsNilOrEmpty ¶
func (snt *StringNumberOrTime) IsNilOrEmpty() bool
func (*StringNumberOrTime) IsNilOrZero ¶
func (snt *StringNumberOrTime) IsNilOrZero() bool
IsNilOrZero indiciates whether SNT is nil, empty string, or zero value
func (*StringNumberOrTime) IsNumber ¶
func (snt *StringNumberOrTime) IsNumber() bool
func (StringNumberOrTime) IsString ¶
func (snt StringNumberOrTime) IsString() bool
IsString reports whether the value is a string
func (*StringNumberOrTime) IsTime ¶
func (snt *StringNumberOrTime) IsTime(layout ...string) bool
func (StringNumberOrTime) MarshalJSON ¶
func (snt StringNumberOrTime) MarshalJSON() ([]byte, error)
func (*StringNumberOrTime) Number ¶
func (snt *StringNumberOrTime) Number() interface{}
Number returns the underlying value of Number. It could be: int64, uint64, float64, or nil. If you need specific types, use their corresponding methods.
func (*StringNumberOrTime) Set ¶
func (snt *StringNumberOrTime) Set(value interface{}) error
Set sets the value of StringNumberOrTime to value. The type of value can be any of the following:
string, []byte, dynamic.String, fmt.Stringer, []string, *string, time.Time, *time.Time, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
All pointer values are dereferenced.
Set returns an error if value is not one of the aforementioned types
func (StringNumberOrTime) String ¶
func (snt StringNumberOrTime) String() string
func (*StringNumberOrTime) Time ¶
func (snt *StringNumberOrTime) Time(layout ...string) (time.Time, bool)
Time returns the Time value and true. If the original value is a string, Time attempts to parse it with the DefaultTimeLayouts or the provided layouts
func (*StringNumberOrTime) Uint ¶
func (snt *StringNumberOrTime) Uint() (uint, bool)
func (*StringNumberOrTime) Uint16 ¶
func (snt *StringNumberOrTime) Uint16() (uint16, bool)
func (*StringNumberOrTime) Uint32 ¶
func (snt *StringNumberOrTime) Uint32() (uint32, bool)
func (*StringNumberOrTime) Uint64 ¶
func (snt *StringNumberOrTime) Uint64() (uint64, bool)
func (*StringNumberOrTime) Uint8 ¶
func (snt *StringNumberOrTime) Uint8() (uint8, bool)
func (*StringNumberOrTime) UnmarshalJSON ¶
func (snt *StringNumberOrTime) UnmarshalJSON(data []byte) error
func (StringNumberOrTime) Value ¶
func (snt StringNumberOrTime) Value() interface{}
type StringOrArrayOfStrings ¶
type StringOrArrayOfStrings []string
func (*StringOrArrayOfStrings) Add ¶
func (sas *StringOrArrayOfStrings) Add(v string)
func (StringOrArrayOfStrings) GetIndex ¶
func (sas StringOrArrayOfStrings) GetIndex(i int) (string, error)
func (StringOrArrayOfStrings) IndexOf ¶
func (sas StringOrArrayOfStrings) IndexOf(v string) int
func (*StringOrArrayOfStrings) IsEmpty ¶
func (sas *StringOrArrayOfStrings) IsEmpty() bool
func (*StringOrArrayOfStrings) IsNil ¶
func (sas *StringOrArrayOfStrings) IsNil() bool
func (*StringOrArrayOfStrings) Iterate ¶
func (sas *StringOrArrayOfStrings) Iterate(fn func(string) error) error
Iterate calls fn for each value of sas until an error is returned. If the error returned is dynamic.Done, nil is returned to the caller. Otherwise the error returned from fn is passed along.
func (StringOrArrayOfStrings) MarshalJSON ¶
func (sas StringOrArrayOfStrings) MarshalJSON() ([]byte, error)
MarshalJSON satisfies json.Marshaler interface
func (*StringOrArrayOfStrings) RemoveIndex ¶
func (sas *StringOrArrayOfStrings) RemoveIndex(i int) error
func (*StringOrArrayOfStrings) Set ¶
func (sas *StringOrArrayOfStrings) Set(v interface{}) error
func (*StringOrArrayOfStrings) UnmarshalJSON ¶
func (sas *StringOrArrayOfStrings) UnmarshalJSON(data []byte) error
UnmarshalJSON satisfies json.Unmarshaler interface
type StringOrNumber ¶
type StringOrNumber struct {
// contains filtered or unexported fields
}
func NewStringOrNumber ¶
func NewStringOrNumber(value interface{}) (StringOrNumber, error)
NewStringOrNumber returns a new StringOrNumber set to the first value, if any.
String can be set to any of the following:
string, []byte, dynamic.String, fmt.Stringer, []string, *string, time.Time, *time.Time, int, int64, int32, int16, int8, *int, *int64, *int32, *int16, *int8, uint, uint64, uint32, uint16, uint8, *uint, *uint64, *uint32, *uint16, *uint8 float64, float32, complex128, complex64, *float64, *float32, *complex128, *complex64 bool, *bool nil
checking, use:
v := &dynamic.StringOrNumber{} err := v.Set(myType)
func NewStringOrNumberPtr ¶
func NewStringOrNumberPtr(value interface{}) (*StringOrNumber, error)
func (*StringOrNumber) Bool ¶
func (sn *StringOrNumber) Bool() (bool, bool)
func (*StringOrNumber) Clear ¶
func (sn *StringOrNumber) Clear()
Clear sets the value of StringOrNumber to nil
func (*StringOrNumber) Float32 ¶
func (sn *StringOrNumber) Float32() (float32, bool)
func (*StringOrNumber) Float64 ¶
func (sn *StringOrNumber) Float64() (float64, bool)
func (*StringOrNumber) Int ¶
func (sn *StringOrNumber) Int() (int, bool)
func (*StringOrNumber) Int16 ¶
func (sn *StringOrNumber) Int16() (int16, bool)
func (*StringOrNumber) Int32 ¶
func (sn *StringOrNumber) Int32() (int32, bool)
func (*StringOrNumber) Int64 ¶
func (sn *StringOrNumber) Int64() (int64, bool)
func (*StringOrNumber) Int8 ¶
func (sn *StringOrNumber) Int8() (int8, bool)
func (*StringOrNumber) IsBool ¶
func (sn *StringOrNumber) IsBool() bool
IsBool reports whether the value is a boolean or a string representation of a boolean.
The underlying type of StringOrNumber is altered from a string to a bool if the value is successfully parsed.
func (*StringOrNumber) IsEmptyString ¶
func (sn *StringOrNumber) IsEmptyString() bool
IsEmptyString returns true if sn is nil or an empty string
func (StringOrNumber) IsNil ¶
func (sn StringOrNumber) IsNil() bool
func (*StringOrNumber) IsNumber ¶
func (sn *StringOrNumber) IsNumber() bool
func (StringOrNumber) IsString ¶
func (sn StringOrNumber) IsString() bool
IsString reports whether the value is a string
Note: if you've used any of the other type checks before this that reported true, the string may have been cast and is no longer a string.
func (*StringOrNumber) IsTime ¶
func (sn *StringOrNumber) IsTime(layout ...string) bool
func (StringOrNumber) MarshalJSON ¶
func (sn StringOrNumber) MarshalJSON() ([]byte, error)
func (*StringOrNumber) Number ¶
func (sn *StringOrNumber) Number() interface{}
Number returns the underlying value of Number. It could be: int64, uint64, float64, or nil. If you need specific types, use their corresponding methods.
func (*StringOrNumber) Set ¶
func (sn *StringOrNumber) Set(value interface{}) error
Set sets the value of StringOrNumber to value. The type of value can be any of the following:
time.Time, *time.Time string, *string json.Number, *json.Number float64, *float64, float32, *float32 int, *int, int64, *int64, int32, *int32, int16, *int16, int8, *int8 uint, *uint, uint64, *uint64, uint32, *uint32, uint16, *uint16, uint8, *uint8 bool, *bool fmt.Stringer nil
All pointer values are dereferenced.
Set returns an error if value is not one of the aforementioned types
func (StringOrNumber) String ¶
func (sn StringOrNumber) String() string
func (*StringOrNumber) Time ¶
func (sn *StringOrNumber) Time(layout ...string) (time.Time, bool)
Time returns the Time value and true. If the original value is a string, Time attempts to parse it with the DefaultTimeLayouts or the provided layouts
func (*StringOrNumber) Uint ¶
func (sn *StringOrNumber) Uint() (uint, bool)
func (*StringOrNumber) Uint16 ¶
func (sn *StringOrNumber) Uint16() (uint16, bool)
func (*StringOrNumber) Uint32 ¶
func (sn *StringOrNumber) Uint32() (uint32, bool)
func (*StringOrNumber) Uint64 ¶
func (sn *StringOrNumber) Uint64() (uint64, bool)
func (*StringOrNumber) Uint8 ¶
func (sn *StringOrNumber) Uint8() (uint8, bool)
func (*StringOrNumber) UnmarshalJSON ¶
func (sn *StringOrNumber) UnmarshalJSON(data []byte) error
func (StringOrNumber) Value ¶
func (sn StringOrNumber) Value() interface{}
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
func (Time) MarshalJSON ¶
func (Time) Time ¶
Time returns the underlying value and true if not nil. If it is nil, a zero value time is returned and false, indicating as such.
func (*Time) UnmarshalJSON ¶
Notes ¶
Bugs ¶
The rule Title uses for word boundaries does not handle Unicode punctuation properly.