Documentation ¶
Overview ¶
Package types proviedes types that can be represented as Watson.
Index ¶
- type Kind
- type Marshaler
- type TypeMismatch
- type Unmarshaler
- type Value
- func NewArrayValue(val []*Value) *Value
- func NewBoolValue(val bool) *Value
- func NewFloatValue(val float64) *Value
- func NewIntValue(val int64) *Value
- func NewNilValue() *Value
- func NewObjectValue(val map[string]*Value) *Value
- func NewStringValue(val []byte) *Value
- func NewUintValue(val uint64) *Value
- func ToValue(v interface{}) (*Value, error)
- func ToValueByReflection(v reflect.Value) (*Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TypeMismatch ¶
type TypeMismatch struct {
// contains filtered or unexported fields
}
TypeMismatch is an error that indicates that a given Value can't be converted into expected type.
func (*TypeMismatch) Error ¶
func (e *TypeMismatch) Error() string
type Unmarshaler ¶
By implementing Unmarshaler you can configure converting Values into go objects.
type Value ¶
type Value struct { Kind Kind Int int64 Uint uint64 Float float64 String []byte Object map[string]*Value Array []*Value Bool bool }
Value is an arbitrary value that can be represented as Watson.
func NewArrayValue ¶
NewArrayValue creates a new value that contains an array.
func NewBoolValue ¶
NewBoolValue creates a new Value that contains a bool.
func NewFloatValue ¶
NewFloatValue creates a new Value that contains a floating point number.
func NewIntValue ¶
NewIntValue creates a new Value that contains an integer.
func NewObjectValue ¶
NewObjectValue creates a new Value that contains an object.
func NewStringValue ¶
NewStringValue creates a new Value that contains a string.
func NewUintValue ¶
NewUintValue creates a new Value that contains an unsigned integer.
func ToValueByReflection ¶
`ToValueByReflection` does almost the same thing as `ToValue`, but it always uses reflection.
func (*Value) Bind ¶
Bind converts v into any go object and assigns it to `to`.
See watson.Marshal for more details.
func (*Value) BindByReflection ¶
BindByReflection is almost the same as Bind but it always uses reflection.
func (*Value) ToGoObject ¶
func (val *Value) ToGoObject() interface{}
ToGoObject converts Value into one of the following type:
- int64
- uint64
- float64
- string
- bool
- (interface{})(nil)
- []interface{} (the element of which is also one or many of these types)
- map[string]interface{} (the value of which is also one or many of these types)