config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config provides configuration loading for ctxweaver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CarrierDef

type CarrierDef struct {
	Package  string `yaml:"package" json:"package"`
	Type     string `yaml:"type" json:"type"`
	Accessor string `yaml:"accessor" json:"accessor,omitempty"`
}

CarrierDef defines a context carrier type.

func (CarrierDef) BuildContextExpr

func (c CarrierDef) BuildContextExpr(varName string) string

BuildContextExpr builds the expression to access context.Context from a variable.

type CarrierRegistry

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

CarrierRegistry holds all registered carriers for quick lookup.

func NewCarrierRegistry

func NewCarrierRegistry() *CarrierRegistry

NewCarrierRegistry creates a registry with default carriers loaded.

func (*CarrierRegistry) All

func (r *CarrierRegistry) All() []CarrierDef

All returns all registered carriers.

func (*CarrierRegistry) Lookup

func (r *CarrierRegistry) Lookup(packagePath, typeName string) (CarrierDef, bool)

Lookup finds a carrier by package path and type name.

func (*CarrierRegistry) Register

func (r *CarrierRegistry) Register(c CarrierDef)

Register adds a carrier to the registry.

type CarriersFile

type CarriersFile struct {
	Carriers []CarrierDef `yaml:"carriers"`
}

CarriersFile represents the structure of carriers.yaml.

type Config

type Config struct {
	// Template is the Go template for the statement to insert
	Template string `yaml:"template" json:"template,omitempty"`
	// TemplateFile is a path to a file containing the template (alternative to Template)
	TemplateFile string `yaml:"template_file" json:"template_file,omitempty"`
	// Imports are the imports to add when the template is inserted
	Imports []string `yaml:"imports" json:"imports,omitempty"`
	// Carriers are additional context carrier definitions
	Carriers []CarrierDef `yaml:"carriers" json:"carriers,omitempty"`
	// Patterns are the package patterns to process (e.g., "./...")
	Patterns []string `yaml:"patterns" json:"patterns,omitempty"`
	// Test indicates whether to process test files
	Test bool `yaml:"test" json:"test,omitempty"`
	// Hooks are shell commands to run before and after processing
	Hooks Hooks `yaml:"hooks" json:"hooks,omitempty"`
}

Config represents the user configuration file.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads a configuration file.

type Hooks

type Hooks struct {
	// Pre are shell commands to run before processing
	Pre []string `yaml:"pre" json:"pre,omitempty"`
	// Post are shell commands to run after processing
	Post []string `yaml:"post" json:"post,omitempty"`
}

Hooks defines shell commands to run before and after processing.

Jump to

Keyboard shortcuts

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