dataset

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package dataset merge-loads a directory of YAML data files into one set of top-level sections and decodes each section strictly into a typed value, so a front-end's repository data (tools, paths, checks) can be split across files by topic without a key silently overriding another or a misspelled field being dropped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dataset

type Dataset struct {
	// contains filtered or unexported fields
}

Dataset is the merged top-level sections of a directory of YAML files.

func Load

func Load(fsys fs.FS, dir string) (*Dataset, error)

Load reads every *.yaml file directly in dir of fsys, in name order, and merges their top-level keys. A file that does not parse, or a key defined in two files, is CodeInvalidInput naming the file (both files for a duplicate).

func (*Dataset) Decode added in v0.0.19

func (d *Dataset) Decode(out any) error

Decode decodes every section of d into the matching field of the struct out points to. A section matches the exported field whose yaml tag name equals its key (an untagged field matches its lower-cased name). out must be a non-nil pointer to a struct; a key with no field, or a section that does not fit its field (a field the type does not declare included), is CodeInvalidInput naming the section's file. A field with no section keeps its zero value.

func (*Dataset) Section

func (d *Dataset) Section[T any](name string) (T, error)

Section decodes the top-level section name into a T, rejecting a field T does not declare. A missing section is CodeNotFound; a section that does not fit T is CodeInvalidInput naming the section's file.

Jump to

Keyboard shortcuts

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