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 ApplyDefaultsOrZero[S any](fs ...func(*S)) *S
- 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 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 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 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) }