utils

package
v0.180.1 Latest Latest
Warning

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

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

Documentation

Overview

Package utils provides generic file-IO helpers shared by every sub-config in package config. They are deliberately domain-agnostic - anything that knows about a specific config type belongs in package config itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadYAML

func LoadYAML[T any](path, label string, defaults func() *T) (*T, error)

LoadYAML reads path. If the file does not exist, defaults() is returned so callers can treat absence as "use defaults" without special-casing. The file body is run through os.ExpandEnv so ${VAR} references resolve from the environment before unmarshalling - any future content that needs a literal `${…}` token must escape it as `$$…`.

label scopes error messages, e.g. "channels" produces "failed to read channels config: …".

func LoadYAMLMerged added in v0.178.0

func LoadYAMLMerged[T any](path, label string, defaults func() *T) (*T, error)

LoadYAMLMerged is LoadYAML except the file is decoded OVER the defaults, so keys absent from an existing file keep their default value instead of the zero value. Use it for configs where new fields must not silently load as false/0 for users whose file was seeded before the field existed (e.g. a computer-use tool added after their computer_use.yaml was written).

func SaveYAML

func SaveYAML[T any](path, label string, cfg *T) error

SaveYAML writes cfg to path, creating any missing parent directories. It always emits the YAML document marker `---\n` and uses 2-space indent.

Types

This section is empty.

Jump to

Keyboard shortcuts

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