Documentation ¶
Overview ¶
Package util is a generated GoMock package.
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 FileLine(fn interface{}) (file string, line int, fnName string)
- func HasReceiver(t reflect.Type, receiver reflect.Value) bool
- func Indirect(t reflect.Type) reflect.Type
- func IsBeanReceiver(t reflect.Type) bool
- func IsBeanType(t reflect.Type) bool
- func IsConstructor(t reflect.Type) bool
- func IsContextType(t reflect.Type) bool
- func IsConverter(t reflect.Type) bool
- func IsErrorType(t reflect.Type) bool
- func IsFuncType(t reflect.Type) bool
- func IsPrimitiveValueType(t reflect.Type) bool
- func IsStructPtr(t reflect.Type) bool
- func IsValueType(t reflect.Type) bool
- func LocalIPv4() string
- func MD5(str string) string
- func PatchValue(v reflect.Value) reflect.Value
- func ReadDirNames(dirname string) ([]string, error)
- func ReturnNothing(t reflect.Type) bool
- func ReturnOnlyError(t reflect.Type) bool
- func SafeCloseChan(ch chan struct{})
- func TypeName(i interface{}) string
- func Wrap(err error, fileline string, text string) error
- func Wrapf(err error, fileline string, format string, a ...interface{}) error
- type BeanDefinition
- type BeanSelector
- type Converter
- type MockBeanDefinition
- func (m *MockBeanDefinition) BeanName() string
- func (m *MockBeanDefinition) Created() bool
- func (m *MockBeanDefinition) EXPECT() *MockBeanDefinitionMockRecorder
- func (m *MockBeanDefinition) ID() string
- func (m *MockBeanDefinition) Interface() interface{}
- func (m *MockBeanDefinition) Type() reflect.Type
- func (m *MockBeanDefinition) TypeName() string
- func (m *MockBeanDefinition) Value() reflect.Value
- func (m *MockBeanDefinition) Wired() bool
- type MockBeanDefinitionMockRecorder
- func (mr *MockBeanDefinitionMockRecorder) BeanName() *gomock.Call
- func (mr *MockBeanDefinitionMockRecorder) Created() *gomock.Call
- func (mr *MockBeanDefinitionMockRecorder) ID() *gomock.Call
- func (mr *MockBeanDefinitionMockRecorder) Interface() *gomock.Call
- func (mr *MockBeanDefinitionMockRecorder) Type() *gomock.Call
- func (mr *MockBeanDefinitionMockRecorder) TypeName() *gomock.Call
- func (mr *MockBeanDefinitionMockRecorder) Value() *gomock.Call
- func (mr *MockBeanDefinitionMockRecorder) Wired() *gomock.Call
- type MockBeanSelector
- type MockBeanSelectorMockRecorder
- type MockConverter
- type MockConverterMockRecorder
- type PanicCond
Constants ¶
This section is empty.
Variables ¶
var ForbiddenMethod = errors.New("forbidden method")
ForbiddenMethod throws this error when calling a method is prohibited.
var UnimplementedMethod = errors.New("unimplemented method")
UnimplementedMethod throws this error when calling an unimplemented method.
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 Error ¶
Error returns an error with the file and line. The file and line may be calculated at the compile time in the future.
func Errorf ¶
Errorf returns an error with the file and line. The file and line may be calculated at the compile time in the future.
func HasReceiver ¶
HasReceiver returns whether the function has a receiver.
func IsBeanReceiver ¶ added in v1.1.1
IsBeanReceiver returns whether the `t` is a bean receiver, a bean receiver can be a bean, a map or slice whose elements are beans.
func IsBeanType ¶ added in v1.1.1
IsBeanType returns whether `t` is a bean type.
func IsConstructor ¶
IsConstructor returns whether `t` is a constructor type. What is a constructor? It should be a function first, has any number of inputs and supports the option pattern input, has one or two outputs and the second output should be an error.
func IsContextType ¶
IsContextType returns whether `t` is context.Context type.
func IsConverter ¶ added in v1.1.3
IsConverter returns whether `t` is a converter type.
func IsErrorType ¶
IsErrorType returns whether `t` is error type.
func IsPrimitiveValueType ¶
IsPrimitiveValueType returns whether `t` is the primitive value type which only is int, unit, float, bool, string and complex.
func IsStructPtr ¶
IsStructPtr returns whether it is the pointer type of structure.
func IsValueType ¶
IsValueType returns whether the input type is the primitive value type and their composite type including array, slice, map and struct, such as []int, [3]string, []string, map[int]int, map[string]string, etc.
func PatchValue ¶
PatchValue makes an unexported field can be assignable.
func ReadDirNames ¶
ReadDirNames reads the directory named by dirname and returns an unsorted list of directory entries.
func ReturnNothing ¶
ReturnNothing returns whether the function has no return value.
func ReturnOnlyError ¶
ReturnOnlyError returns whether the function returns only error value.
func TypeName ¶ added in v1.1.1
func TypeName(i interface{}) string
TypeName returns a fully qualified name consisting of package path and type name.
Types ¶
type BeanDefinition ¶ added in v1.1.1
type BeanDefinition interface { Type() reflect.Type Value() reflect.Value Interface() interface{} ID() string BeanName() string TypeName() string Created() bool Wired() bool }
A BeanDefinition describes a bean whose lifecycle is managed by IoC container.
type BeanSelector ¶ added in v1.1.1
type BeanSelector interface{}
A BeanSelector can be the ID of a bean, a `reflect.Type`, a pointer such as `(*error)(nil)`, or a BeanDefinition value.
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 MockBeanDefinition ¶ added in v1.1.1
type MockBeanDefinition struct {
// contains filtered or unexported fields
}
MockBeanDefinition is a mock of BeanDefinition interface.
func NewMockBeanDefinition ¶ added in v1.1.1
func NewMockBeanDefinition(ctrl *gomock.Controller) *MockBeanDefinition
NewMockBeanDefinition creates a new mock instance.
func (*MockBeanDefinition) BeanName ¶ added in v1.1.1
func (m *MockBeanDefinition) BeanName() string
BeanName mocks base method.
func (*MockBeanDefinition) Created ¶ added in v1.1.1
func (m *MockBeanDefinition) Created() bool
Created mocks base method.
func (*MockBeanDefinition) EXPECT ¶ added in v1.1.1
func (m *MockBeanDefinition) EXPECT() *MockBeanDefinitionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockBeanDefinition) ID ¶ added in v1.1.1
func (m *MockBeanDefinition) ID() string
ID mocks base method.
func (*MockBeanDefinition) Interface ¶ added in v1.1.1
func (m *MockBeanDefinition) Interface() interface{}
Interface mocks base method.
func (*MockBeanDefinition) Type ¶ added in v1.1.1
func (m *MockBeanDefinition) Type() reflect.Type
Type mocks base method.
func (*MockBeanDefinition) TypeName ¶ added in v1.1.1
func (m *MockBeanDefinition) TypeName() string
TypeName mocks base method.
func (*MockBeanDefinition) Value ¶ added in v1.1.1
func (m *MockBeanDefinition) Value() reflect.Value
Value mocks base method.
func (*MockBeanDefinition) Wired ¶ added in v1.1.1
func (m *MockBeanDefinition) Wired() bool
Wired mocks base method.
type MockBeanDefinitionMockRecorder ¶ added in v1.1.1
type MockBeanDefinitionMockRecorder struct {
// contains filtered or unexported fields
}
MockBeanDefinitionMockRecorder is the mock recorder for MockBeanDefinition.
func (*MockBeanDefinitionMockRecorder) BeanName ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) BeanName() *gomock.Call
BeanName indicates an expected call of BeanName.
func (*MockBeanDefinitionMockRecorder) Created ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) Created() *gomock.Call
Created indicates an expected call of Created.
func (*MockBeanDefinitionMockRecorder) ID ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) ID() *gomock.Call
ID indicates an expected call of ID.
func (*MockBeanDefinitionMockRecorder) Interface ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) Interface() *gomock.Call
Interface indicates an expected call of Interface.
func (*MockBeanDefinitionMockRecorder) Type ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) Type() *gomock.Call
Type indicates an expected call of Type.
func (*MockBeanDefinitionMockRecorder) TypeName ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) TypeName() *gomock.Call
TypeName indicates an expected call of TypeName.
func (*MockBeanDefinitionMockRecorder) Value ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) Value() *gomock.Call
Value indicates an expected call of Value.
func (*MockBeanDefinitionMockRecorder) Wired ¶ added in v1.1.1
func (mr *MockBeanDefinitionMockRecorder) Wired() *gomock.Call
Wired indicates an expected call of Wired.
type MockBeanSelector ¶ added in v1.1.1
type MockBeanSelector struct {
// contains filtered or unexported fields
}
MockBeanSelector is a mock of BeanSelector interface.
func NewMockBeanSelector ¶ added in v1.1.1
func NewMockBeanSelector(ctrl *gomock.Controller) *MockBeanSelector
NewMockBeanSelector creates a new mock instance.
func (*MockBeanSelector) EXPECT ¶ added in v1.1.1
func (m *MockBeanSelector) EXPECT() *MockBeanSelectorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockBeanSelectorMockRecorder ¶ added in v1.1.1
type MockBeanSelectorMockRecorder struct {
// contains filtered or unexported fields
}
MockBeanSelectorMockRecorder is the mock recorder for MockBeanSelector.
type MockConverter ¶ added in v1.1.1
type MockConverter struct {
// contains filtered or unexported fields
}
MockConverter is a mock of Converter interface.
func NewMockConverter ¶ added in v1.1.1
func NewMockConverter(ctrl *gomock.Controller) *MockConverter
NewMockConverter creates a new mock instance.
func (*MockConverter) EXPECT ¶ added in v1.1.1
func (m *MockConverter) EXPECT() *MockConverterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockConverterMockRecorder ¶ added in v1.1.1
type MockConverterMockRecorder struct {
// contains filtered or unexported fields
}
MockConverterMockRecorder is the mock recorder for MockConverter.
type PanicCond ¶
type PanicCond struct {
// contains filtered or unexported fields
}
PanicCond panic condition.
func NewPanicCond ¶
func NewPanicCond(fn func() interface{}) *PanicCond
NewPanicCond returns a panic condition.
func Panic ¶
func Panic(err interface{}) *PanicCond
Panic returns a panic condition that throws an error.