utils

package
v0.106.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT 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 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