Documentation ¶
Overview ¶
Package settings implements the functions, types, and interfaces for the module.
Package settings implements the functions, types, and interfaces for the module.
Index ¶
- func Apply[S any](s *S, fs []func(*S)) *S
- func ApplyAny[S any](s *S, fs []interface{}) *S
- func ApplyDefaults[S any](s *S, fs []func(*S)) *S
- func ApplyDefaultsOr[S any](s *S, fs ...func(*S)) *S
- func ApplyDefaultsOrError[S any](s *S, fs ...func(*S)) (*S, error)
- func ApplyDefaultsOrZero[S any](fs ...func(*S)) *S
- func ApplyErrorDefaults[S any](s *S, fs []func(*S)) (*S, error)
- func ApplyErrorDefaultsOr[S any](s *S, fs ...func(*S)) (*S, error)
- func ApplyErrorDefaultsOrZero[S any](fs ...func(*S)) (*S, error)
- func ApplyOr[S any](s *S, fs ...func(*S)) *S
- func ApplyOrZero[S any](fs ...func(*S)) *S
- type ApplyFunc
- type ApplySetting
- type Defaulter
- type ErrorDefaulter
- type Setting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyAny ¶
func ApplyAny[S any](s *S, fs []interface{}) *S
ApplyAny Applies a set of setting functions to a struct. These Settings functions can be ApplyFunc[S] or func(*S), or objects that implement the ApplySetting interface.
func ApplyDefaults ¶ added in v0.1.2
func ApplyDefaults[S any](s *S, fs []func(*S)) *S
ApplyDefaults applies the given settings and default settings to the provided value.
It first applies the given settings using the Apply function, then checks if the value implements the Defaulter interface. If it does, it calls the ApplyDefaults method to apply the default settings.
func ApplyDefaultsOr ¶ added in v0.1.2
func ApplyDefaultsOr[S any](s *S, fs ...func(*S)) *S
ApplyDefaultsOr applies the given settings and default settings to the provided value.
It is a convenience wrapper around ApplyDefaults that accepts a variable number of setting functions.
func ApplyDefaultsOrError ¶ added in v0.1.3
ApplyDefaultsOrError applies the given settings and default settings to the provided value.
It is a convenience wrapper around ApplyDefaults that accepts a variable number of setting functions.
func ApplyDefaultsOrZero ¶ added in v0.1.2
func ApplyDefaultsOrZero[S any](fs ...func(*S)) *S
ApplyDefaultsOrZero applies the given settings and default settings to a zero value of the type.
It creates a zero value of the type, then calls ApplyDefaults to apply the given settings and default settings.
func ApplyErrorDefaults ¶ added in v0.1.3
ApplyErrorDefaults applies the given settings and default settings to the provided value.
It first applies the given settings using the Apply function, then checks if the value implements the ErrorDefaulter interface. If it does, it calls the ApplyDefaults method
func ApplyErrorDefaultsOr ¶ added in v0.1.3
ApplyErrorDefaultsOr applies the given settings and default settings to the provided value.
It is a convenience wrapper around ApplyDefaults that accepts a variable number of interface{} values.
func ApplyErrorDefaultsOrZero ¶ added in v0.1.3
ApplyErrorDefaultsOrZero applies the given settings and default settings to a zero value of the type.
It creates a zero value of the type, then calls ApplyDefaults to apply the given settings and default settings.
func ApplyOr ¶
func ApplyOr[S any](s *S, fs ...func(*S)) *S
ApplyOr is an apply settings with defaults
func ApplyOrZero ¶
func ApplyOrZero[S any](fs ...func(*S)) *S
ApplyOrZero is an apply settings with defaults
Types ¶
type ApplySetting ¶
type ApplySetting[S any] interface { Apply(v *S) }
type Defaulter ¶ added in v0.1.2
type Defaulter interface {
// ApplyDefaults applies the default settings to the implementing type.
ApplyDefaults()
}
Defaulter is an interface that provides a method to apply default settings.
type ErrorDefaulter ¶ added in v0.1.3
type ErrorDefaulter interface { // ApplyDefaults applies the default settings to the implementing type and returns an error. ApplyDefaults() error }
ErrorDefaulter is an interface that provides a method to apply default settings and return an error.