Documentation
¶
Index ¶
- Constants
- Variables
- func ContainType()
- func CopyProperties(source interface{}, target interface{}) error
- func DereferenceInterfaceValue(v reflect.Value) reflect.Value
- func DereferencePtrValue(v reflect.Value) reflect.Value
- func DereferenceType(t reflect.Type) reflect.Type
- func DereferenceValue(v reflect.Value) reflect.Value
- func GetCustomizeTag(customize, key string) string
- func GetDereferenceType(typ reflect.Type) reflect.Type
- func GetFieldValue(src interface{}, dst interface{}) bool
- func Hash(v interface{}) uint32
- func OriginalType(typ reflect.Type) reflect.Type
- func RuntimeTypeID(t reflect.Type) uintptr
- func Set(o interface{}, field string, v interface{})
- func SetField(src interface{}, sub interface{}) bool
- func SetFieldValue(srcValue reflect.Value, subValue reflect.Value) bool
- func SetStructByJSON(obj interface{}, mapData map[string]interface{}) error
- func TypeInfo(v interface{})
- type ChanType
- type Converter
- type Eface
- type EmptyInterface
- type Flag
- type Func
- type FuncID
- type Iface
- type Imethod
- type InterfaceType
- type Itab
- type MapType
- type Name
- type NameOff
- type NonEmptyInterface
- type PtrType
- type ReflectInvoker
- func (r *ReflectInvoker) InvokeByInterfaceArgs(funcName string, Params []interface{}) []reflect.Value
- func (r *ReflectInvoker) InvokeByJson(byteData []byte) []byte
- func (r *ReflectInvoker) InvokeByReflectArgs(funcName string, par []reflect.Value) []reflect.Value
- func (r *ReflectInvoker) RegisterMethod(v interface{})
- type Request
- type Response
- type Rtype
- type SliceType
- type StructField
- type StructTag
- type StructType
- type Tag
- type Tags
- func (t *Tags) AddOptions(key string, options ...string)
- func (t *Tags) Delete(keys ...string)
- func (t *Tags) DeleteOptions(key string, options ...string)
- func (t *Tags) Get(key string) (*Tag, error)
- func (t *Tags) Keys() []string
- func (t *Tags) Len() int
- func (t *Tags) Less(i int, j int) bool
- func (t *Tags) Set(tag *Tag) error
- func (t *Tags) String() string
- func (t *Tags) Swap(i int, j int)
- func (t *Tags) Tags() []*Tag
- type TextOff
- type Tflag
- type Type
- type TypeOff
- type Value
Constants ¶
const ( NoError = "NoError" JsonError = "JsonError" MethodNotFound = "MethodNotFound" ParameterNotMatch = "ParameterNotMatch" )
Variables ¶
var ( PtrOffset = func() uintptr { return unsafe.Offsetof(e.Word) }() KindOffset = func() uintptr { return unsafe.Offsetof(e.Typ.Kind) }() ElemOffset = func() uintptr { return unsafe.Offsetof(new(PtrType).Elem) }() SliceDataOffset = func() uintptr { return unsafe.Offsetof(new(reflect.SliceHeader).Data) }() )
var Converters = map[reflect.Kind]Converter{ reflect.Bool: convertBool, reflect.Float32: convertFloat32, reflect.Float64: convertFloat64, reflect.Int: convertInt, reflect.Int8: convertInt8, reflect.Int16: convertInt16, reflect.Int32: convertInt32, reflect.Int64: convertInt64, reflect.String: convertString, reflect.Uint: convertUint, reflect.Uint8: convertUint8, reflect.Uint16: convertUint16, reflect.Uint32: convertUint32, reflect.Uint64: convertUint64, }
Default converters for basic types.
Functions ¶
func ContainType ¶
func ContainType()
func CopyProperties ¶
func CopyProperties(source interface{}, target interface{}) error
func DereferenceInterfaceValue ¶
DereferenceInterfaceValue returns the value of the underlying type that implements the interface v.
func DereferencePtrValue ¶
DereferencePtrValue returns the underlying non-pointer type value.
func DereferenceValue ¶
DereferenceValue dereference and unpack interface, get the underlying non-pointer and non-interface value.
func GetCustomizeTag ¶
func RuntimeTypeID ¶
func SetStructByJSON ¶
SetStructByJSON 由json对象生成 struct
Types ¶
type ChanType ¶
type ChanType struct {
Rtype
Elem *Rtype // channel element type
Dir uintptr // channel direction (ChanDir)
}
ChanType represents a channel type.
type EmptyInterface ¶
type Flag ¶
type Flag uintptr
const ( FlagKindWidth = 5 // there are 27 kinds FlagKindMask Flag = 1<<FlagKindWidth - 1 FlagStickyRO Flag = 1 << 5 FlagEmbedRO Flag = 1 << 6 FlagIndir Flag = 1 << 7 FlagAddr Flag = 1 << 8 FlagMethod Flag = 1 << 9 FlagMethodShift = 10 FlagRO Flag = FlagStickyRO | FlagEmbedRO )
type Func ¶
type Func struct {
Entry uintptr // start pc
Nameoff int32 // function name
Args int32 // in/out args size
Deferreturn uint32 // offset of start of a deferreturn call instruction from entry, if any.
Pcsp uint32
Pcfile uint32
Pcln uint32
Npcdata uint32
CuOffset uint32 // runtime.cutab offset of this function's CU
FuncID FuncID // set for certain special runtime functions
Nfuncdata uint8 // must be last
// contains filtered or unexported fields
}
type InterfaceType ¶
interfaceType represents an interface type.
type MapType ¶
type MapType struct {
Rtype
Key *Rtype // map key type
Elem *Rtype // map element (value) type
Bucket *Rtype // internal bucket structure
// function for hashing keys (ptr to key, seed) -> hash
Hasher func(unsafe.Pointer, uintptr) uintptr
Keysize uint8 // size of key slot
Valuesize uint8 // size of value slot
Bucketsize uint16 // size of bucket
Flags uint32
}
MapType represents a map type.
type NonEmptyInterface ¶
type NonEmptyInterface struct {
// see ../runtime/iface.go:/Itab
Itab *struct {
Ityp *Rtype // static interface type
Typ *Rtype // dynamic concrete type
Hash uint32 // copy of typ.hash
Fun [100000]unsafe.Pointer // method table
// contains filtered or unexported fields
}
Word unsafe.Pointer
}
NonEmptyInterface is the header for an interface value with methods.
type ReflectInvoker ¶
func NewReflectinvoker ¶
func NewReflectinvoker() *ReflectInvoker
func (*ReflectInvoker) InvokeByInterfaceArgs ¶
func (r *ReflectInvoker) InvokeByInterfaceArgs(funcName string, Params []interface{}) []reflect.Value
func (*ReflectInvoker) InvokeByJson ¶
func (r *ReflectInvoker) InvokeByJson(byteData []byte) []byte
func (*ReflectInvoker) InvokeByReflectArgs ¶
func (*ReflectInvoker) RegisterMethod ¶
func (r *ReflectInvoker) RegisterMethod(v interface{})
type Request ¶
type Request struct {
FuncName string `json:"funcName"`
Params []interface{} `json:"params"`
}
type Response ¶
type Rtype ¶
type Rtype struct {
Size uintptr
Ptrdata uintptr // number of bytes in the type that can contain pointers
Hash uint32 // hash of type; avoids computation in hash tables
Align uint8 // alignment of variable with this type
FieldAlign uint8 // alignment of struct field with this type
Kind uint8 // enumeration for C
// function for comparing objects of this type
// (ptr to object A, ptr to object B) -> ==?
Equal func(unsafe.Pointer, unsafe.Pointer) bool
Gcdata *byte // garbage collection data
Str NameOff // string form
PtrToThis TypeOff // type for pointer to this type, may be zero
// contains filtered or unexported fields
}
Rtype must be kept in sync with ../runtime/type.go:/^type._type.
type StructField ¶
type StructField struct {
Name Name // name is always non-empty
Typ *Rtype // type of field
OffsetEmbed uintptr // byte offset of field<<1 | isEmbedded
}
Struct field
type StructType ¶
type StructType struct {
Rtype
PkgPath Name
Fields []StructField // sorted by offset
}
StructType represents a struct type.
type Tag ¶
type Tag struct {
// Key is the tag key, such as json, xml, etc..
// i.e: `json:"foo,omitempty". Here key is: "json"
Key string
// Name is a part of the value
// i.e: `json:"foo,omitempty". Here name is: "foo"
Name string
// Options is a part of the value. It contains a Slice of tag options i.e:
// `json:"foo,omitempty". Here options is: ["omitempty"]
Options []string
}
Tag defines a single struct's string literal tag
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags represent a set of tags from a single struct field
func (*Tags) AddOptions ¶
AddOptions adds the given option for the given key. If the option already exists it doesn't add it again.
func (*Tags) DeleteOptions ¶
DeleteOptions deletes the given options for the given key
func (*Tags) Get ¶
Get returns the tag associated with the given key. If the key is present in the tag the value (which may be empty) is returned. Otherwise the returned value will be the empty string. The ok return value reports whether the tag exists or not (which the return value is nil).
func (*Tags) Keys ¶
Tags returns a Slice of tags. The order is the original tag order unless it was changed.
type Type ¶
type Type struct {
Size uintptr
Ptrdata uintptr // size of memory prefix holding all pointers
Hash uint32
Tflag Tflag
Align uint8
FieldAlign uint8
Kind uint8
// function for comparing objects of this type
// (ptr to object A, ptr to object B) -> ==?
Equal func(unsafe.Pointer, unsafe.Pointer) bool
// gcdata stores the GC type data for the garbage collector.
// If the KindGCProg bit is set in kind, gcdata is a GC program.
// Otherwise it is a ptrmask bitmap. See mbitmap.go for details.
Gcdata *byte
Str NameOff
PtrToThis TypeOff
}