configfile

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package configfile reads structured configuration files (Team, Loop, Roster, and future Workflow/Controller definitions) and decodes them into caller-supplied Go values. JSON, YAML, and TOML are supported; the format is detected from the file extension.

Non-JSON formats are normalized through a JSON intermediate so that DisallowUnknownFields semantics and json struct tags are applied uniformly across all formats. This keeps deferred or misspelled fields from silently becoming no-ops regardless of how the author chose to write the file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(path string, data []byte, dst any) error

Decode decodes raw config bytes into dst. The path is used only for format detection. This is useful when the caller has already read the file (for example to apply a pre-processing step) or is working with embedded data.

func Load

func Load(path string, dst any) error

Load reads a config file and decodes it into dst. The format is detected from the file extension: .json (default), .yaml/.yml, or .toml. Unknown fields are rejected in all formats. For non-JSON formats the content is first decoded into a generic value and re-encoded as JSON so that the strict json.Decoder path and json struct tags apply uniformly.

Types

type Format

type Format int

Format identifies the encoding of a config file.

const (
	// FormatJSON is the default and requires no external dependencies.
	FormatJSON Format = iota
	// FormatYAML covers .yaml and .yml extensions.
	FormatYAML
	// FormatTOML covers .toml extensions.
	FormatTOML
)

func DetectFormat

func DetectFormat(path string) Format

DetectFormat infers the config format from the file extension. Unknown extensions default to JSON so that existing callers that pass paths without an explicit extension continue to work.

Jump to

Keyboard shortcuts

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