process

package
v0.0.10 Latest Latest
Warning

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

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

Documentation

Overview

Package process provides reflection-based config struct hydration. It populates struct fields from environment variables, CLI flags, and default values using struct tags, then runs post-parse validation via the Processor interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PreProcess

func PreProcess(target interface{}, flags *pflag.FlagSet) *diagnostic.Diagnostics

PreProcess walks the target struct and hydrates fields based on struct tags. Fields tagged with `env:"VAR"` are populated from environment variables, `default:"val"` sets a fallback when no env var is found and the field is zero, and `flag:"name"` registers a pflag on the provided FlagSet. Nested structs are recursed into unless they implement pflag.Value, in which case they are treated as leaf values. The target must be a pointer to a struct.

func Process

func Process(target interface{})

Process walks the target struct and calls Process on any fields (or the target itself) that implement Processor. The target must be a pointer to a struct.

Types

type Processor

type Processor interface {
	Process()
}

Processor is implemented by config structs that need post-parse validation or derived computation. Process is called depth-first (children before parents) after flags have been parsed.

type SharedFlag

type SharedFlag interface {
	pflag.Value
	AddTarget(target *string)
}

SharedFlag implementations can share the value they're give with other structs in a single operation.

Jump to

Keyboard shortcuts

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