Documentation
¶
Overview ¶
Package pattern provides several patterns
Index ¶
- func ContextKeyAnnotation(contextKey any) cli.Action
- func IDAnnotation[T any](id T) cli.Action
- func IdFlag[T any](id T, uses cli.Action) *cli.Flag
- func LookupContextKey(target any) (any, bool)
- func LookupID[T any](target any) (T, bool)
- func Unmarshal[T ~int, Index uint8 | uint16](id *T, data []byte, names string, index []Index) error
- type Cacheable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextKeyAnnotation ¶ added in v0.13.0
func ContextKeyAnnotation(contextKey any) cli.Action
func IDAnnotation ¶ added in v0.13.0
func IDAnnotation[T any](id T) cli.Action
IDAnnotation provides an action which annotates a flag or arg with the identity id. The annotation is placed early and only to flags and args directly defined by the package.
func IdFlag ¶ added in v0.13.0
func IdFlag[T any](id T, uses cli.Action) *cli.Flag
IdFlag creates a flag which uses the given action and carries the identity annotation id.
func LookupContextKey ¶ added in v0.13.0
Types ¶
type Cacheable ¶
type Cacheable[T comparable] struct { // contains filtered or unexported fields }
Cacheable provides a value that can be set or calculated from a factory. Aside from this, it accumulates and applies middleware using a common function signature
func (*Cacheable[T]) AddMiddleware ¶
AddMiddleware adds a middleware function that will be applied with the result is calculated
func (*Cacheable[T]) Discrete ¶
func (c *Cacheable[T]) Discrete() T
Discrete the discrete value to use as the basis of the result
func (*Cacheable[T]) New ¶
New creates the value, either from the discrete value or the factory and applies the middleware. The result is cached, and if an error is generated it is returned on each of the subsequent calls.
func (*Cacheable[T]) SetDiscrete ¶
func (c *Cacheable[T]) SetDiscrete(value T)
SetDiscrete sets a discrete value to use as the basis of the result