factory

package
v0.0.0-...-2f30d10 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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.

View Source
const ValueTag = "value"

ValueTag is a shortcut of wire:"value:"

View Source
const WireTag = "wire"

WireTag is a constant that defines the annotation string used for wire injection in Go code.

Variables

View Source
var ErrInvalidWireValue = errors.New("not a valid WireValue")

Functions

func AutoWire

func AutoWire(self any) error

func Find

func Find[T any]() *T

func FindByName

func FindByName[T any](name string) *T

func Get

func Get[T any]() *T

func NamedSingleton

func NamedSingleton[T any](name string) *singleton[T]

func New

func New[T any]() *T

func NewWithOption

func NewWithOption[T any](option *Option) *T

func Put

func Put[T any](t *T)

func Range

func Range[T any](rangeFunc func(any) bool)

func RangeInterface

func RangeInterface[T any](interfaceFunc func(T) bool)

func RangeStruct

func RangeStruct[T any](structFunc func(*T) bool)

func SetPoolInit

func SetPoolInit[T any](option *Option)

func Singleton

func Singleton[T any]() *singleton[T]

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) Error

func (e *Error) Error() string

func (*Error) WrappedErrors

func (e *Error) WrappedErrors() []error

WrappedErrors implements the errwrap.Wrapper interface to make this return value more useful with the errwrap and go-multierror libraries.

type Getter

type Getter func() any

type Option

type Option struct {
	// contains filtered or unexported fields
}

func NewOption

func NewOption() *Option

func (*Option) InitMethodName

func (o *Option) InitMethodName(initMethodName string) *Option

func (*Option) InitParams

func (o *Option) InitParams(initParams ...string) *Option

func (*Option) UseConstructor

func (o *Option) UseConstructor(useConstructor bool) *Option

type TagValue

type TagValue[T any] struct {
	Tag   T
	Value string
}

func ParseTagValue

func ParseTagValue(tagValue string, checkAndSet func(tv *TagValue[WireValue])) (tv *TagValue[WireValue], err error)

func (*TagValue[T]) String

func (tv *TagValue[T]) String() string

type WireValue

type WireValue string

WireValue is an enum @EnumConfig(marshal, values, noComments, noCase) @Enum{self, auto, type, name, value}

const (
	WireValueSelf  WireValue = "self"
	WireValueAuto  WireValue = "auto"
	WireValueType  WireValue = "type"
	WireValueName  WireValue = "name"
	WireValueValue WireValue = "value"
)

func ParseWireValue

func ParseWireValue(value string) (WireValue, error)

func WireValueValues

func WireValueValues() []WireValue

func (WireValue) IsValid

func (x WireValue) IsValid() bool

func (WireValue) MarshalText

func (x WireValue) MarshalText() ([]byte, error)

func (WireValue) Name

func (x WireValue) Name() string

func (WireValue) String

func (x WireValue) String() string

func (*WireValue) UnmarshalText

func (x *WireValue) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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