Documentation ¶
Index ¶
- Variables
- func Contract(filename string, maxLength int) string
- func Error(fileline string, text string) error
- func Errorf(fileline string, format string, a ...interface{}) error
- func HasReceiver(t reflect.Type, receiver reflect.Type) bool
- func IsConstructor(t reflect.Type) bool
- func IsContextType(t reflect.Type) bool
- func IsErrorType(t reflect.Type) bool
- func IsFuncType(t reflect.Type) bool
- func IsNil(v reflect.Value) bool
- func IsPrimitiveValueType(t reflect.Type) bool
- func IsStructPtr(t reflect.Type) bool
- func IsValidConverter(t reflect.Type) bool
- func IsValueType(t reflect.Type) bool
- func ReturnNothing(t reflect.Type) bool
- func ReturnOnlyError(t reflect.Type) bool
- func T(a ...interface{}) []interface{}
- func Wrap(err error, fileline string, text string) error
- func Wrapf(err error, fileline string, format string, a ...interface{}) error
- type Converter
- type PanicCond
Constants ¶
This section is empty.
Variables ¶
var ForbiddenMethod = errors.New("forbidden method")
ForbiddenMethod 如果某个方法禁止被调用则可以抛出此错误。
var UnimplementedMethod = errors.New("unimplemented method")
UnimplementedMethod 如果某个方法未实现则可以抛出此错误。
var WrapFormat = func(err error, fileline string, format string, a ...interface{}) error { if err == nil { if format != "" { return fmt.Errorf(fileline+" "+format, a...) } return errors.New(fileline + " " + fmt.Sprint(a...)) } if format == "" { return fmt.Errorf("%s %s; %w", fileline, fmt.Sprint(a...), err) } return fmt.Errorf("%s %s; %w", fileline, fmt.Sprintf(format, a...), err) }
Functions ¶
func HasReceiver ¶
HasReceiver 函数是否具有接收者。
func IsConstructor ¶
IsConstructor 返回以函数形式注册 bean 的函数是否合法。一个合法 的注册函数需要以下条件:入参可以有任意多个,支持一般形式和 Option 形式,返回值只能有一个或者两个,第一个返回值必须是 bean 源,它可以是 结构体等值类型也可以是指针等引用类型,为值类型时内部会自动转换为引用类 型(获取可引用的地址),如果有第二个返回值那么它必须是 error 类型。
func IsContextType ¶
IsContextType t 是否是 context.Context 类型。
func IsPrimitiveValueType ¶
IsPrimitiveValueType returns whether the input type is the primitive value type which only is int, unit, float, bool, string and complex.
func IsValueType ¶
IsValueType returns whether the input type is the value type which is the primitive value type and their one dimensional composite type including array, slice, map and struct, such as [3]string, []string, []int, map[int]int, etc.
Types ¶
type Converter ¶
type Converter interface{}
Converter converts string value into user-defined value. It should be function type, and its prototype is func(string)(type,error).
type PanicCond ¶
type PanicCond struct {
// contains filtered or unexported fields
}
PanicCond 封装触发 panic 的条件。
func NewPanicCond ¶
func NewPanicCond(fn func() interface{}) *PanicCond
NewPanicCond PanicCond 的构造函数。