structs

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyTools

func ApplyTools(v any, tc ToolContext, tools ...*Tool) gomerr.Gomerr

func Preprocess

func Preprocess(v any, tools ...*Tool) gomerr.Gomerr

func RegisterToolFunction

func RegisterToolFunction(name string, function ToolFunction) gomerr.Gomerr

func RegisterToolFunctions

func RegisterToolFunctions(functions map[string]ToolFunction) gomerr.Gomerr

func RegisterValueConstants

func RegisterValueConstants(constants map[string]any)

func ScopeAlias

func ScopeAlias(alias, scope string)

ScopeAlias allows the caller to specify an alternative value to use when defining scoped configuration from the scope used during the application of a tool. Aliases need to be defined before PrepareTool() is called.

func ScopeAliases

func ScopeAliases(aliasToScope map[string]string)

func SetNowToolFunctionPrecision

func SetNowToolFunctionPrecision(precision time.Duration)

func ValueFromStruct

func ValueFromStruct(sv reflect.Value, fv reflect.Value, source string) (any, gomerr.Gomerr)

Types

type Applier

type Applier interface {
	Apply(structValue reflect.Value, fieldValue reflect.Value, toolContext ToolContext) gomerr.Gomerr
}

func Composite

func Composite(directive string, tool *Tool, st reflect.Type, sf reflect.StructField) (Applier, gomerr.Gomerr)

Composite checks for a composition directive (one of 'if', '?', '&' or '!') and if found, creates a composed Applier from the directive. If there isn't a composition directive, this returns nil for both Applier and gomerr.Gomerr. TODO:p2 this should perhaps be a default intermediary similar to how the scope applier can be

func ExpressionApplierProvider

func ExpressionApplierProvider(directive string) (Applier, gomerr.Gomerr)

type ApplierProvider

type ApplierProvider interface {
	Applier(structType reflect.Type, structField reflect.StructField, directive string, scope string) (Applier, gomerr.Gomerr)
}

type DirectiveProvider

type DirectiveProvider interface {
	Get(structField reflect.StructField) (string, bool)
}

type MissingDirectiveHandler added in v0.3.0

type MissingDirectiveHandler interface {
	DefaultDirective() string
}

MissingDirectiveHandler can be implemented by an ApplierProvider to indicate that fields without the struct tag should still be processed. The returned string is used as the default directive.

type NoApplier

type NoApplier struct{}

func (NoApplier) Apply

type StructApplier

type StructApplier struct {
	Source string
}

func (StructApplier) Apply

type StructTagDirectiveProvider

type StructTagDirectiveProvider struct {
	TagKey string
}

func (StructTagDirectiveProvider) Get

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool contains references to some behavior that can be applied to structs present in an application.

func NewTool

func NewTool(toolType string, ap ApplierProvider, dp DirectiveProvider) *Tool

func (*Tool) ApplierProvider

func (t *Tool) ApplierProvider() ApplierProvider

func (*Tool) Id

func (t *Tool) Id() string

func (*Tool) Type

func (t *Tool) Type() string

type ToolContext

type ToolContext map[string]any

func EnsureContext

func EnsureContext(tcs ...ToolContext) ToolContext

func ToolContextWithScope

func ToolContextWithScope(scope string) ToolContext

func (ToolContext) Delete added in v0.2.0

func (tc ToolContext) Delete(key string) any

func (ToolContext) Descend

func (tc ToolContext) Descend(location string, createIntermediates bool) (ToolContext, bool)

func (ToolContext) Get

func (tc ToolContext) Get(key string) any

func (ToolContext) Lookup

func (tc ToolContext) Lookup(key string) (any, bool)

func (ToolContext) LookupNested

func (tc ToolContext) LookupNested(key string) (ToolContext, bool)

func (ToolContext) Put

func (tc ToolContext) Put(key string, value any) any

func (ToolContext) PutScope

func (tc ToolContext) PutScope(scope string) string

func (ToolContext) Scope

func (tc ToolContext) Scope() string

func (ToolContext) With added in v0.2.0

func (tc ToolContext) With(key string, value any) ToolContext

type ToolFunction

type ToolFunction func(structValue reflect.Value, fieldValue reflect.Value, toolContext ToolContext) (output any, ge gomerr.Gomerr)

func GetToolFunction

func GetToolFunction(name string) ToolFunction

func (ToolFunction) Apply

type ValueApplier

type ValueApplier struct {
	StaticValue string
}

func (ValueApplier) Apply

Jump to

Keyboard shortcuts

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