gf: github.com/gogf/gf/g/container/gvar Index | Files

package gvar

import "github.com/gogf/gf/g/container/gvar"

Package gvar provides an universal variable type, like generics.

Index

Package Files

gvar.go

type Var Uses

type Var struct {
    // contains filtered or unexported fields
}

Var is an universal variable type.

func New Uses

func New(value interface{}, unsafe ...bool) *Var

New returns a new Var with given <value>. The parameter <unsafe> used to specify whether using Var in un-concurrent-safety, which is false in default, means concurrent-safe.

func (*Var) Bool Uses

func (v *Var) Bool() bool

Bool converts and returns <v> as bool.

func (*Var) Bytes Uses

func (v *Var) Bytes() []byte

Bytes converts and returns <v> as []byte.

func (*Var) Duration Uses

func (v *Var) Duration() time.Duration

Duration converts and returns <v> as time.Duration. If value of <v> is string, then it uses time.ParseDuration for conversion.

func (*Var) Float32 Uses

func (v *Var) Float32() float32

Float32 converts and returns <v> as float32.

func (*Var) Float64 Uses

func (v *Var) Float64() float64

Float64 converts and returns <v> as float64.

func (*Var) Floats Uses

func (v *Var) Floats() []float64

Floats converts and returns <v> as []float64.

func (*Var) GTime Uses

func (v *Var) GTime(format ...string) *gtime.Time

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) Int Uses

func (v *Var) Int() int

Int converts and returns <v> as int.

func (*Var) Int16 Uses

func (v *Var) Int16() int16

Int16 converts and returns <v> as int16.

func (*Var) Int32 Uses

func (v *Var) Int32() int32

Int32 converts and returns <v> as int32.

func (*Var) Int64 Uses

func (v *Var) Int64() int64

Int64 converts and returns <v> as int64.

func (*Var) Int8 Uses

func (v *Var) Int8() int8

Int8 converts and returns <v> as int8.

func (*Var) Interface Uses

func (v *Var) Interface() interface{}

Interface is alias of Val.

func (*Var) Interfaces Uses

func (v *Var) Interfaces() []interface{}

Interfaces converts and returns <v> as []interfaces{}.

func (*Var) Ints Uses

func (v *Var) Ints() []int

Ints converts and returns <v> as []int.

func (*Var) IsNil Uses

func (v *Var) IsNil() bool

IsNil checks whether <v> is nil.

func (*Var) Map Uses

func (v *Var) Map(tags ...string) map[string]interface{}

Map converts <v> to map[string]interface{}.

func (*Var) MapDeep Uses

func (v *Var) MapDeep(tags ...string) map[string]interface{}

MapDeep converts <v> to map[string]interface{} recursively.

func (*Var) MarshalJSON Uses

func (v *Var) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Var) Set Uses

func (v *Var) Set(value interface{}) (old interface{})

Set sets <value> to <v>, and returns the old value.

func (*Var) String Uses

func (v *Var) String() string

String converts and returns <v> as string.

func (*Var) Strings Uses

func (v *Var) Strings() []string

Strings converts and returns <v> as []string.

func (*Var) Struct Uses

func (v *Var) Struct(pointer interface{}, mapping ...map[string]string) error

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 Uses

func (v *Var) StructDeep(pointer interface{}, mapping ...map[string]string) error

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) Structs Uses

func (v *Var) Structs(pointer interface{}, mapping ...map[string]string) (err error)

Structs converts <v> to given struct slice.

func (*Var) StructsDeep Uses

func (v *Var) StructsDeep(pointer interface{}, mapping ...map[string]string) (err error)

StructsDeep converts <v> to given struct slice recursively.

func (*Var) Time Uses

func (v *Var) Time(format ...string) time.Time

Time converts and returns <v> as time.Time. The parameter <format> specifies the format of the time string using gtime, eg: Y-m-d H:i:s.

func (*Var) Uint Uses

func (v *Var) Uint() uint

Uint converts and returns <v> as uint.

func (*Var) Uint16 Uses

func (v *Var) Uint16() uint16

Uint16 converts and returns <v> as uint16.

func (*Var) Uint32 Uses

func (v *Var) Uint32() uint32

Uint32 converts and returns <v> as uint32.

func (*Var) Uint64 Uses

func (v *Var) Uint64() uint64

Uint64 converts and returns <v> as uint64.

func (*Var) Uint8 Uses

func (v *Var) Uint8() uint8

Uint8 converts and returns <v> as uint8.

func (*Var) Val Uses

func (v *Var) Val() interface{}

Val returns the current value of <v>.

Package gvar imports 5 packages (graph) and is imported by 21 packages. Updated 2019-07-15. Refresh now. Tools for package owners.