gotype

package
v0.0.0-...-6c31828 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2013 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxUint8  uint8  = 255
	MaxUint16 uint16 = 65535
	MaxUint32 uint32 = 4294967295
	MaxUint64 uint64 = 18446744073709551615
	MaxInt8   int8   = 127
	MaxInt16  int16  = 32767
	MaxInt32  int32  = 2147483647
	MaxInt64  int64  = 9223372036854775807
	MinInt8   int8   = -128
	MinInt16  int16  = -32768
	MinInt32  int32  = -2147483648
	MinInt64  int64  = -9223372036854775808
)

Variables

View Source
var (
	TypeBool      = reflect.TypeOf(false)
	TypeInt       = reflect.TypeOf(int(0))
	TypeInt8      = reflect.TypeOf(int8(0))
	TypeInt16     = reflect.TypeOf(int16(0))
	TypeInt32     = reflect.TypeOf(int32(0))
	TypeInt64     = reflect.TypeOf(int64(0))
	TypeUint      = reflect.TypeOf(uint(0))
	TypeUint8     = reflect.TypeOf(uint8(0))
	TypeUint16    = reflect.TypeOf(uint16(0))
	TypeUint32    = reflect.TypeOf(uint32(0))
	TypeUint64    = reflect.TypeOf(uint64(0))
	TypeFloat32   = reflect.TypeOf(float32(0))
	TypeFloat64   = reflect.TypeOf(float64(0))
	TypeString    = reflect.TypeOf("")
	TypeByteSlice = reflect.TypeOf([]byte(nil))
)

Functions

func Atok

func Atok(str string, k reflect.Kind) (output reflect.Value, err error)

convert string to reflect.Value acoring to kind( use base 0 to parse numeric )

func Atov

func Atov(str string, typ reflect.Type) (output reflect.Value, err error)

convert string to reflect.Value accoring to type( use base 0 to parse numeric )

func BToi

func BToi(b bool) int

convert bool to int, true=1; false=0

func CanCompareKind

func CanCompareKind(a, b reflect.Kind) bool

can compare a & b ?

func CanCompareValue

func CanCompareValue(a, b reflect.Value) bool

can compare a & b ?

func CanPointer

func CanPointer(kind reflect.Kind) bool

is a pointer?

func CanTypeElem

func CanTypeElem(kind reflect.Kind) bool

has element type?

func CanValueElem

func CanValueElem(kind reflect.Kind) bool

value can element?

func Compare

func Compare(a interface{}, b interface{}) int

compare a and b, return 0 (a==b), 1 (a > b), -1 (a<b)

func Equal

func Equal(a interface{}, b interface{}) bool

a == b?, just compare simple data type

func FieldByName

func FieldByName(v reflect.Value, name string) (field reflect.Value, ok bool)

get public field by name

func FieldByNameFold

func FieldByNameFold(v reflect.Value, name string) (field reflect.Value, ok bool)

get public field by name ignore case

func Fields

func Fields(typ reflect.Type) []string

get fields name

func Greater

func Greater(a interface{}, b interface{}) (result bool)

a > b?, just compare simple data type

func IsBool

func IsBool(kind reflect.Kind) bool

is boolean?

func IsCollect

func IsCollect(kind reflect.Kind) bool

is collect?

func IsFloat

func IsFloat(kind reflect.Kind) bool

is float type?

func IsInt

func IsInt(kind reflect.Kind) bool

is int type?

func IsNumeric

func IsNumeric(kind reflect.Kind) bool

is numeric type?

func IsSimple

func IsSimple(kind reflect.Kind) bool

is simple type(boo, string, numeric)?

func IsString

func IsString(kind reflect.Kind) bool

is string?

func IsStruct

func IsStruct(kind reflect.Kind) bool

is struct?

func IsUint

func IsUint(kind reflect.Kind) bool

is Uint type?

func Less

func Less(a interface{}, b interface{}) bool

a < b?, just compare simple data type

func MethodByName

func MethodByName(v reflect.Value, name string) (m reflect.Value, ok bool)

get public method by name

func MethodByNameFold

func MethodByNameFold(v reflect.Value, name string) (m reflect.Value, ok bool)

get public method by name ignore case

func SetAddr

func SetAddr(a reflect.Value, b reflect.Value)

set a as addrss of b

func ToBool

func ToBool(input reflect.Value) (output bool, err error)

convert to bool

func ToFloat

func ToFloat(input reflect.Value) (output float64, err error)

convert to float64

func ToInt

func ToInt(input reflect.Value) (output int64, err error)

convert to int64

func ToMap

func ToMap(input reflect.Value) map[string]reflect.Value

convert struct to map[string]reflect.Value

func ToString

func ToString(input reflect.Value) (output string, err error)

convert to string

func ToUint

func ToUint(input reflect.Value) (output uint64, err error)

convert to uint64

func Underlying

func Underlying(v reflect.Value) reflect.Value

get underlying value of *struct

func UnderlyingKind

func UnderlyingKind(v reflect.Value) reflect.Kind

get kind of underlying value

func UnderlyingType

func UnderlyingType(typ reflect.Type) reflect.Type

get underlying element type

Types

type MethodInfo

type MethodInfo struct {
	Method reflect.Method

	// Type
	Type reflect.Type

	// Value
	Func reflect.Value

	// NumIn is number of input paramter
	NumIn int

	// NumOut is number of output paramter
	NumOut int

	// Ins is input parameter type
	In []reflect.Type

	// Outs is output parameter type
	Out []reflect.Type
}

func GetMethodInfo

func GetMethodInfo(method reflect.Method) *MethodInfo

func GetMethodInfoByValue

func GetMethodInfoByValue(fnValue reflect.Value) *MethodInfo

func (*MethodInfo) String

func (m *MethodInfo) String() string

type TypeError

type TypeError struct {
	Func    string      // the failing function
	Message string      // the error message
	Inner   interface{} // reference value
}

go type error

func (*TypeError) Error

func (e *TypeError) Error() string

Error interface of TypeError

type Value

type Value reflect.Value

Value is a alias of reflect.Value

func ValueOf

func ValueOf(i interface{}) Value

get underlying value of *struct

func (Value) CanCompareTo

func (v Value) CanCompareTo(i reflect.Value) bool

can compare with i ?

func (Value) CanElem

func (v Value) CanElem() bool

can call Elem()?

func (Value) CanPointer

func (v Value) CanPointer() bool

can call Pointer()

func (Value) Fields

func (v Value) Fields() []string

return fields name

func (Value) Format

func (v Value) Format() string

func (Value) FromStr_Todel

func (v Value) FromStr_Todel(str string)

prase value from a string

func (Value) IsBool

func (v Value) IsBool() bool

is boolean?

func (Value) IsCollect

func (v Value) IsCollect() bool

is boolean?

func (Value) IsEmptyValue

func (v Value) IsEmptyValue() bool

func (Value) IsFloat

func (v Value) IsFloat() bool

is numeric type?

func (Value) IsInt

func (v Value) IsInt() bool

is numeric type?

func (Value) IsNumeric

func (v Value) IsNumeric() bool

is numeric type?

func (Value) IsSimple

func (v Value) IsSimple() bool

is numeric type?

func (Value) IsString

func (v Value) IsString() bool

is numeric type?

func (Value) IsStruct

func (v Value) IsStruct() bool

is struct?

func (Value) IsUint

func (v Value) IsUint() bool

is numeric type?

func (Value) Parse

func (rv Value) Parse(s string)

Parse value from a string

func (Value) Set

func (v Value) Set(x reflect.Value)

set value to x

func (Value) String

func (v Value) String() string

return string

func (Value) Underlying

func (v Value) Underlying() reflect.Value

return underlying value

func (Value) UnderlyingKind

func (v Value) UnderlyingKind() reflect.Kind

return underlying kind

func (Value) UnderlyingType

func (v Value) UnderlyingType() reflect.Type

return underlying type

func (Value) Value

func (v Value) Value() reflect.Value

origin reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL