Documentation ¶
Overview ¶
Package gvar provides an universal variable type, like generics.
Index ¶
- type Var
- func (v *Var) Array() []interface{}
- func (v *Var) Bool() bool
- func (v *Var) Bytes() []byte
- func (v *Var) Duration() time.Duration
- func (v *Var) Float32() float32
- func (v *Var) Float64() float64
- func (v *Var) Floats() []float64
- func (v *Var) GTime(format ...string) *gtime.Time
- func (v *Var) Int() int
- func (v *Var) Int16() int16
- func (v *Var) Int32() int32
- func (v *Var) Int64() int64
- func (v *Var) Int8() int8
- func (v *Var) Interface() interface{}
- func (v *Var) Interfaces() []interface{}
- func (v *Var) Ints() []int
- func (v *Var) IsEmpty() bool
- func (v *Var) IsNil() bool
- func (v *Var) Map(tags ...string) map[string]interface{}
- func (v *Var) MapDeep(tags ...string) map[string]interface{}
- func (v *Var) MapStrStr(tags ...string) map[string]string
- func (v *Var) MapStrStrDeep(tags ...string) map[string]string
- func (v *Var) MapStrVar(tags ...string) map[string]*Var
- func (v *Var) MapStrVarDeep(tags ...string) map[string]*Var
- func (v *Var) MapToMap(pointer interface{}, mapping ...map[string]string) (err error)
- func (v *Var) MapToMapDeep(pointer interface{}, mapping ...map[string]string) (err error)
- func (v *Var) MapToMaps(pointer interface{}, mapping ...map[string]string) (err error)
- func (v *Var) MapToMapsDeep(pointer interface{}, mapping ...map[string]string) (err error)
- func (v *Var) MarshalJSON() ([]byte, error)
- func (v *Var) Set(value interface{}) (old interface{})
- func (v *Var) Slice() []interface{}
- func (v *Var) String() string
- func (v *Var) Strings() []string
- func (v *Var) Struct(pointer interface{}, mapping ...map[string]string) error
- func (v *Var) StructDeep(pointer interface{}, mapping ...map[string]string) error
- func (v *Var) Structs(pointer interface{}, mapping ...map[string]string) (err error)
- func (v *Var) StructsDeep(pointer interface{}, mapping ...map[string]string) (err error)
- func (v *Var) Time(format ...string) time.Time
- func (v *Var) Uint() uint
- func (v *Var) Uint16() uint16
- func (v *Var) Uint32() uint32
- func (v *Var) Uint64() uint64
- func (v *Var) Uint8() uint8
- func (v *Var) Val() interface{}
- func (v *Var) Vars() []*Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Var ¶
type Var struct {
// contains filtered or unexported fields
}
Var is an universal variable type.
func New ¶
New returns a new Var with given <value>. The parameter <safe> used to specify whether using Var in concurrent-safety, which is false in default.
func (*Var) Duration ¶
Duration converts and returns <v> as time.Duration. If value of <v> is string, then it uses time.ParseDuration for conversion.
func (*Var) GTime ¶
GTime converts and returns <v> as *gtime.Time. The parameter <format> specifies the format of the time string using gtime, eg: Y-m-d H:i:s.
func (*Var) Interfaces ¶
func (v *Var) Interfaces() []interface{}
Interfaces converts and returns <v> as []interfaces{}.
func (*Var) MapStrStrDeep ¶ added in v1.9.3
MapDeep converts <v> to map[string]string recursively.
func (*Var) MapStrVarDeep ¶ added in v1.9.3
MapStrVarDeep converts <v> to map[string]*Var recursively.
func (*Var) MapToMap ¶ added in v1.9.3
MapToMap converts map type variable <params> to another map type variable <pointer>. The elements of <pointer> should be type of struct/*struct.
func (*Var) MapToMapDeep ¶ added in v1.9.3
MapToMapDeep recursively converts map type variable <params> to another map type variable <pointer>. The elements of <pointer> should be type of struct/*struct.
func (*Var) MapToMaps ¶ added in v1.9.3
MapToMaps converts map type variable <params> to another map type variable <pointer>. The elements of <pointer> should be type of []struct/[]*struct.
func (*Var) MapToMapsDeep ¶ added in v1.9.3
MapToMapsDeep recursively converts map type variable <params> to another map type variable <pointer>. The elements of <pointer> should be type of []struct/[]*struct.
func (*Var) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Var) Set ¶
func (v *Var) Set(value interface{}) (old interface{})
Set sets <value> to <v>, and returns the old value.
func (*Var) Struct ¶
Struct maps value of <v> to <pointer>. The parameter <pointer> should be a pointer to a struct instance. The parameter <mapping> is used to specify the key-to-attribute mapping rules.
func (*Var) StructDeep ¶
Struct maps value of <v> to <pointer> recursively. The parameter <pointer> should be a pointer to a struct instance. The parameter <mapping> is used to specify the key-to-attribute mapping rules.
func (*Var) StructsDeep ¶
StructsDeep converts <v> to given struct slice recursively.