Documentation ¶
Index ¶
- func Construct[O Object, FO Option[O] | optionAlias[O]](obj O, opts ...FO) (O, error)
- func ConstructWithContext[O Object, FO OptionWithContext[O] | optionWithContextAlias[O]](ctx context.Context, obj O, opts ...FO) (O, error)
- func ConstructWithContextValidate[O ObjectValidable, FO OptionWithContext[O] | optionWithContextAlias[O]](ctx context.Context, obj O, opts ...FO) (O, error)
- func ConstructWithValidate[O ObjectValidable, FO Option[O] | optionAlias[O]](obj O, opts ...FO) (O, error)
- func New[O Object, FO Option[O] | optionAlias[O]](opts ...FO) (O, error)
- func NewWithContext[O Object, FO OptionWithContext[O] | optionWithContextAlias[O]](ctx context.Context, opts ...FO) (O, error)
- func NewWithContextValidate[O ObjectValidable, FO OptionWithContext[O] | optionWithContextAlias[O]](ctx context.Context, opts ...FO) (O, error)
- func NewWithValidate[O ObjectValidable, FO Option[O] | optionAlias[O]](opts ...FO) (O, error)
- type Object
- type ObjectValidable
- type Option
- type OptionWithContext
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructWithContext ¶
func ConstructWithContext[ O Object, FO OptionWithContext[O] | optionWithContextAlias[O], ]( ctx context.Context, obj O, opts ...FO, ) (O, error)
func ConstructWithContextValidate ¶ added in v0.3.0
func ConstructWithContextValidate[ O ObjectValidable, FO OptionWithContext[O] | optionWithContextAlias[O], ]( ctx context.Context, obj O, opts ...FO, ) (O, error)
func ConstructWithValidate ¶ added in v0.3.0
func ConstructWithValidate[ O ObjectValidable, FO Option[O] | optionAlias[O], ]( obj O, opts ...FO, ) (O, error)
func New ¶
Example ¶
ExampleNew just configures object - no validate applied
opts := []WorkerOption{ WithW(invalidW), nil, WithS(invalidS), nil, WithI(invalidI), nil, } obj, err := New(opts...) if err != nil { panic(err) } fmt.Printf("%s\n", obj)
Output: s=lolkek;i=999;w_is_nil=true;is_valid=false;
func NewWithContext ¶
func NewWithContext[ O Object, FO OptionWithContext[O] | optionWithContextAlias[O], ]( ctx context.Context, opts ...FO, ) (O, error)
Example ¶
ExampleNewWithContext just configures object - no validate applied. Also ctx is required For example - http.Request as struct attribute
ctx := context.TODO() opts := []WorkerOptionWithContext{ WithWCtx(invalidW), nil, WithSCtx(invalidS), nil, WithICtx(invalidI), nil, } obj, err := NewWithContext(ctx, opts...) if err != nil { panic(err) } fmt.Printf("%s\n", obj)
Output: s=lolkek;i=999;w_is_nil=true;is_valid=false;
func NewWithContextValidate ¶ added in v0.3.0
func NewWithContextValidate[ O ObjectValidable, FO OptionWithContext[O] | optionWithContextAlias[O], ]( ctx context.Context, opts ...FO, ) (O, error)
Example ¶
ExampleNewWithContextValidate configures and validates object. Also ctx is required For example - http.Request as struct attribute
ctx := context.TODO() opts := []WorkerOptionWithContext{ WithWCtx(validW), nil, WithSCtx(validS), nil, WithICtx(validI), nil, } obj, err := NewWithContextValidate(ctx, opts...) if err != nil { panic(err) } fmt.Printf("%s\n", obj)
Output: s=foobar;i=100500;w_is_nil=false;is_valid=true;
func NewWithValidate ¶ added in v0.3.0
func NewWithValidate[ O ObjectValidable, FO Option[O] | optionAlias[O], ]( opts ...FO, ) (O, error)
Example ¶
ExampleNewWithValidate configures and validates object
opts := []WorkerOption{ WithW(validW), nil, WithS(validS), nil, WithI(validI), nil, } obj, err := NewWithValidate(opts...) if err != nil { panic(err) } fmt.Printf("%s\n", obj)
Output: s=foobar;i=100500;w_is_nil=false;is_valid=true;
Types ¶
type ObjectValidable ¶ added in v0.3.0
type ObjectValidable interface{ Validate() error }
Click to show internal directories.
Click to hide internal directories.