rulecontext

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package rulecontext implements some helper functions to store values from the standard Go Context package.

Index

Constants

This section is empty.

Variables

View Source
var RuleSetContextKey int

Functions

func Printer

func Printer(ctx context.Context) *message.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

func RuleSet(ctx context.Context) any

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

func WithPathIndex(parent context.Context, value int) context.Context

WithPathIndex returns a new Context with the path segment index added.

func WithPathString

func WithPathString(parent context.Context, value string) context.Context

WithPathString returns a new Context with the path segment added.

func WithPrinter

func WithPrinter(parent context.Context, printer *message.Printer) context.Context

WithPrinters adds a printer key to a context

func WithRuleSet

func WithRuleSet(parent context.Context, ruleSet any) context.Context

WithRuleSet adds a rule set to the 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL