Help us shape the future of Go! Take the 2026 Go Developer Survey

records

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package records is the first record source for `ds:table` (docs/SPEC.md §9.5): a directory of markdown files whose YAML frontmatter holds the fields. Every file is one record; its top-level `key: value` pairs are the columns, plus `path` and `title` (the first heading). SQLite and HTTP sources are adapters that return the same rows.

Index

Constants

View Source
const (
	KeyKind  = "kind"
	KeyWhere = "where"
	KeyCols  = "cols"
	KeySort  = "sort"
	KeyLimit = "limit"

	// Field names every record carries.
	FieldPath  = "path"
	FieldTitle = "title"
	FieldKind  = "kind"
)

Query keys a `ds:table` passes (§9.5).

Variables

View Source
var (
	ErrBadWhere = errors.New("records: where= wants `field=value` or `field!=value` joined by ` and `")
	ErrBadLimit = errors.New("records: limit= must be a positive integer")
)

Errors.

Functions

func Apply

func Apply(rows []map[string]string, args map[string]string) ([]map[string]string, error)

Apply filters, sorts, projects, and limits rows per the query args.

func Parse

func Parse(p, src string) map[string]string

Parse reads one file's top-level frontmatter fields, its path, and its first heading as title. Nested YAML is ignored: a record is flat.

Types

type Source

type Source func(args map[string]string) ([]map[string]string, error)

Source answers table queries; it matches docsync.WithRecords.

func Frontmatter

func Frontmatter(fsys fs.FS, dir string) Source

Frontmatter builds a source over dir in fsys. Files are read on every query so an edit shows on the next render; the directory is small by construction (it is records, not prose).

Jump to

Keyboard shortcuts

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