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 gvar_read.go

type Var Uses

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

func New Uses

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

创建一个动态变量,value参数可以为nil

func (*Var) Bool Uses

func (v *Var) Bool() bool

func (*Var) Bytes Uses

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

func (*Var) Float32 Uses

func (v *Var) Float32() float32

func (*Var) Float64 Uses

func (v *Var) Float64() float64

func (*Var) Floats Uses

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

func (*Var) GTime Uses

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

func (*Var) Int Uses

func (v *Var) Int() int

func (*Var) Int16 Uses

func (v *Var) Int16() int16

func (*Var) Int32 Uses

func (v *Var) Int32() int32

func (*Var) Int64 Uses

func (v *Var) Int64() int64

func (*Var) Int8 Uses

func (v *Var) Int8() int8

func (*Var) Interface Uses

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

Val() 别名

func (*Var) Interfaces Uses

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

func (*Var) Ints Uses

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

func (*Var) IsNil Uses

func (v *Var) IsNil() bool

func (*Var) ReadOnly Uses

func (v *Var) ReadOnly() VarRead

返回动态变量的只读接口

func (*Var) Set Uses

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

func (*Var) String Uses

func (v *Var) String() string

func (*Var) Strings Uses

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

func (*Var) Struct Uses

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

将变量转换为对象,注意 objPointer 参数必须为struct指针

func (*Var) Time Uses

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

func (*Var) TimeDuration Uses

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

func (*Var) Uint Uses

func (v *Var) Uint() uint

func (*Var) Uint16 Uses

func (v *Var) Uint16() uint16

func (*Var) Uint32 Uses

func (v *Var) Uint32() uint32

func (*Var) Uint64 Uses

func (v *Var) Uint64() uint64

func (*Var) Uint8 Uses

func (v *Var) Uint8() uint8

func (*Var) Val Uses

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

type VarRead Uses

type VarRead interface {
    Val() interface{}
    IsNil() bool
    Bytes() []byte
    String() string
    Bool() bool
    Int() int
    Int8() int8
    Int16() int16
    Int32() int32
    Int64() int64
    Uint() uint
    Uint8() uint8
    Uint16() uint16
    Uint32() uint32
    Uint64() uint64
    Float32() float32
    Float64() float64
    Interface() interface{}
    Ints() []int
    Floats() []float64
    Strings() []string
    Interfaces() []interface{}
    Time(format ...string) time.Time
    TimeDuration() time.Duration
    GTime(format ...string) *gtime.Time
    Struct(objPointer interface{}, attrMapping ...map[string]string) error
}

只读变量接口

func NewRead Uses

func NewRead(value interface{}, unsafe ...bool) VarRead

创建一个只读动态变量,value参数可以为nil

Package gvar imports 4 packages (graph) and is imported by 8 packages. Updated 2019-02-11. Refresh now. Tools for package owners.