Documentation ¶
Index ¶
- Constants
- Variables
- func AutoWire(self any) error
- func AutoWireTimeout(self any, timeout time.Duration) error
- func Factory[T any](f any) *_factory
- func FactoryWithType(vt reflect.Type, f any) *_factory
- func Find[T any]() *T
- func FindByName[T any](name string) *T
- func FindByNameTimeout[T any](name string, timeout time.Duration) *T
- func FindInterfaces[T any]() (result []T)
- func FindStructs[T any]() (result []*T)
- func FindTimeout[T any](timeout time.Duration) *T
- func Get[T any]() *T
- func Getter[T any](s *singleton) func() *T
- func IGetter[T any](s *iInterface) func() T
- func Interface[T any]() *iInterface
- func NamedInterface[T any](name string) *iInterface
- func NamedSingleton[T any](name string) *singleton
- func New[T any]() *T
- func NewBeforeInit[T any](f func(*T)) *T
- func NewBeforeInitOption[T any](f func(*T), option *Option) *T
- func NewWithOption[T any](option *Option) *T
- func Put[T any](t *T)
- func Range[T any](rangeFunc func(any) bool)
- func RangeInterface[T any](interfaceFunc func(T) bool)
- func RangeStruct[T any](structFunc func(*T) bool)
- func RangeTimeout[T any](rangeFunc func(any) bool, timeout time.Duration)
- func SetPoolInit[T any](option *Option)
- func Singleton[T any]() *singleton
- type Error
- type Logger
- type Option
- type Tag
- type TagWithValue
- type WireValue
Constants ¶
const DefaultInitMethodName = "Init"
DefaultInitMethodName is a constant representing the default name of the initialization method. It is used in the NewWithOption function to determine the name of the method to invoke during initialization. If the 'initMethodName' field in the Option struct is empty, the DefaultInitMethodName is used. If the 'useConstructor' field in the Option struct is true, the DefaultInitMethodName is set to the name of the struct. The DefaultInitMethodName is used in reflection to find and invoke the initialization method.
const GetterKey = "Getter"
const NewMethodName = "New"
const TimeoutKey = "Timeout"
const TypeKey = "type"
Variables ¶
var ErrInvalidTag = errors.New("not a valid Tag")
var ErrInvalidWireValue = errors.New("not a valid WireValue")
Functions ¶
func FactoryWithType ¶
func FindByName ¶
func FindInterfaces ¶
func FindInterfaces[T any]() (result []T)
func FindStructs ¶
func FindStructs[T any]() (result []*T)
func FindTimeout ¶
func NamedInterface ¶
func NamedSingleton ¶
func NewBeforeInit ¶
func NewBeforeInit[T any](f func(*T)) *T
func NewBeforeInitOption ¶
func NewWithOption ¶
func RangeInterface ¶
func RangeStruct ¶
func SetPoolInit ¶
Types ¶
type Error ¶
type Error struct {
Errors []string
}
copied from github.com/mitchellh/mapstructure Error implements the error interface and can represents multiple errors that occur in the course of a single Decode.
func (*Error) WrappedErrors ¶
WrappedErrors implements the errwrap.Wrapper interface to make this return value more useful with the errwrap and go-multierror libraries.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
func (*Option) InitMethodName ¶
func (*Option) InitParams ¶
func (*Option) UseConstructor ¶
type Tag ¶
type Tag string
Tag is an enum @Enum{wire, value, new}
type TagWithValue ¶
func ParseTagValue ¶
func ParseTagValue(tagValue string, checkAndSet func(tv *TagWithValue)) (tv *TagWithValue, err error)
func (*TagWithValue) String ¶
func (tv *TagWithValue) String() string
type WireValue ¶
type WireValue string
WireValue is an enum @EnumConfig(marshal, values, noComments, noCase) @Enum{self, auto, type, name, value}
func ParseWireValue ¶
ParseWireValue converts a string to a WireValue.
func WireValueValues ¶
func WireValueValues() []WireValue
WireValueValues returns a list of the values of WireValue
func (WireValue) IsValid ¶
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (WireValue) MarshalText ¶
MarshalText implements the text marshaller method.
func (*WireValue) UnmarshalText ¶
UnmarshalText implements the text unmarshaller method.