utils

package
v0.0.0-...-d986d38 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBoolType

func IsBoolType(kind reflect.Kind) bool

IsBoolType 是否布尔类型

func IsFloatType

func IsFloatType(kind reflect.Kind) bool

IsFloatType 是否浮点类型

func IsIntType

func IsIntType(kind reflect.Kind) bool

IsIntType 是否整数类型

func IsStringType

func IsStringType(kind reflect.Kind) bool

IsStringType 是否字符串类型

func IsStructType

func IsStructType(kind reflect.Kind) bool

IsStructType 是否结构类型

func IsTimeType

func IsTimeType(typ reflect.Type) bool

IsTimeType 是否时间类型

func ParseFieldDesc

func ParseFieldDesc(field *reflect.StructField) string

ParseFieldDesc 解析字段说明

func ParseStructFieldName

func ParseStructFieldName(field *reflect.StructField) string

ParseStructFieldName 解析结构字段名称

func ParseValueCheckers

func ParseValueCheckers(prop *TypeProp, field *reflect.StructField)

ParseValueCheckers 解析数据验证定义

func StructFieldTypeToGraphType

func StructFieldTypeToGraphType(field *reflect.StructField) (grapghType graphql.Output, isStruct bool)

StructFieldTypeToGraphType 结构字段类型对应 graphql 类型

func TypeToGraphQLType

func TypeToGraphQLType(typ reflect.Type) (outType graphql.Output, isStruct bool, err error)

TypeToGraphQLType go 类型转 graphql 类型

Types

type FloatMax

type FloatMax struct {
	Max   float64
	Equal bool
}

FloatMax 监测整形最大值

func (*FloatMax) Passed

func (fmax *FloatMax) Passed(val interface{}) error

type FloatMin

type FloatMin struct {
	Min   float64
	Equal bool
}

FloatMin 监测整形最小值

func (*FloatMin) Passed

func (fmin *FloatMin) Passed(val interface{}) error

type FuncInfo

type FuncInfo struct {
	Name string // 名称
	Pkg  string // 包
}

FuncInfo 函数信息

func ParseFuncInfo

func ParseFuncInfo(aFunc interface{}) *FuncInfo

ParseFuncInfo 解析函数信息

func (*FuncInfo) FullName

func (f *FuncInfo) FullName() string

FullName 函数的完整名称

type IntegerMax

type IntegerMax struct {
	Max   int
	Equal bool
}

IntegerMax 监测整形最大值

func (*IntegerMax) Passed

func (imax *IntegerMax) Passed(val interface{}) error

type IntegerMin

type IntegerMin struct {
	Min   int
	Equal bool
}

IntegerMax 监测整形最小值

func (*IntegerMin) Passed

func (imin *IntegerMin) Passed(val interface{}) error

type StringMax

type StringMax struct {
	Max   int
	Equal bool
}

StringMax 监测整形最大值

func (*StringMax) Passed

func (smax *StringMax) Passed(val interface{}) error

type StringMin

type StringMin struct {
	Min   int
	Equal bool
}

StringMin 监测整形最小值

func (*StringMin) Passed

func (smin *StringMin) Passed(val interface{}) error

type TypeProp

type TypeProp struct {
	SrcType     reflect.Type // 原始类型
	TypeName    string       // 真正的类型名称
	PackageName string       // 包名称
	Kind        reflect.Kind // 真正的类型
	RealType    reflect.Type // 真正的类型,对于 切片和指针 来说

	IsPrimitive bool // 是否原生类型
	IsPtr       bool // 是否指针
	IsList      bool // 是否列表,切片

	// 以下属性来自于对 tag 的解析
	ValChecker []ValueChecker
	Desc       string
}

TypeProp 类型属性

func ParseTypeProp

func ParseTypeProp(typ reflect.Type) *TypeProp

ParseTypeProp 解析类型属性

func (*TypeProp) IsContext

func (t *TypeProp) IsContext() bool

IsContext 是否是 context.Context 接口

func (*TypeProp) Key

func (t *TypeProp) Key() string

Key 类型唯一标识

func (*TypeProp) KeyOfList

func (t *TypeProp) KeyOfList() string

KeyOfList 切片类型唯一标识

func (*TypeProp) String

func (t *TypeProp) String() string

String 转为字符串

type ValueChecker

type ValueChecker interface {
	Passed(val interface{}) error
}

ValueChecker 数据检查

Jump to

Keyboard shortcuts

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