Documentation ¶
Overview ¶
Package rulecontext implements some helper functions to store values from the standard Go Context package.
Index ¶
- Variables
- func Printer(ctx context.Context) *message.Printer
- func RuleSet(ctx context.Context) any
- func WithPathIndex(parent context.Context, value int) context.Context
- func WithPathString(parent context.Context, value string) context.Context
- func WithPrinter(parent context.Context, printer *message.Printer) context.Context
- func WithRuleSet(parent context.Context, ruleSet any) context.Context
- type PathSegment
Constants ¶
This section is empty.
Variables ¶
View Source
var RuleSetContextKey int
Functions ¶
func Printer ¶
Printer returns the most recent printer from the context. If none is found it returns the default printer.
This function never returns nil.
func RuleSet ¶
RuleSet returns the most resent rule set.
For nested objects there may be more than one but only the most recent can be retrieved.
func WithPathIndex ¶
WithPathIndex returns a new Context with the path segment index added.
func WithPathString ¶
WithPathString returns a new Context with the path segment added.
func WithPrinter ¶
WithPrinters adds a printer key to a context
Types ¶
type PathSegment ¶
type PathSegment interface { Parent() PathSegment String() string FullString() string }
func Path ¶
func Path(ctx context.Context) PathSegment
Path returns the most recently added path segment, which can then be used to build out the full path.
Click to show internal directories.
Click to hide internal directories.