Documentation
¶
Overview ¶
Package sourcefile loads configuration from YAML, JSON, or TOML files.
Format is auto-detected from extension (.yaml, .json, .toml).
Example:
source := sourcefile.New("config.yaml", sourcefile.Options{Required: true})
loader := rigging.NewLoader[Config]().WithSource(source)
Subtree example:
source := sourcefile.New("config.yaml", sourcefile.Options{
Root: "root.section",
})
loader := rigging.NewLoader[Config]().WithSource(source)
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrRootNotFound is returned when Options.Root does not exist in the parsed file. ErrRootNotFound = errors.New("sourcefile: root not found") // ErrRootNotMap is returned when Options.Root resolves to a non-map value. ErrRootNotMap = errors.New("sourcefile: root is not a map") // ErrInvalidRoot is returned when Options.Root has invalid dot-path syntax. ErrInvalidRoot = errors.New("sourcefile: invalid root path") )
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Format: "yaml", "json", or "toml". Auto-detected from extension if empty.
Format string
// Required: if true, missing files cause an error. Default: false (returns empty map).
Required bool
// Root selects a dot-separated map path inside the parsed file (for example, "root.section").
// When set, only that subtree is flattened and exposed as the source root.
Root string
}
Options configures file source behavior.
Click to show internal directories.
Click to hide internal directories.