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

schema

package
v0.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Root    string   `yaml:"root"`
	Include []string `yaml:"include"`
	Exclude []string `yaml:"exclude"`
	Mark    struct {
		LLMCmd          string `yaml:"llm_cmd"`
		LLMExcerptBytes int    `yaml:"llm_excerpt_bytes"`
	} `yaml:"mark"`
	Index struct {
		Template string `yaml:"template"`
		Output   string `yaml:"output"`
	} `yaml:"index"`
	Output struct {
		DefaultFormat string `yaml:"default_format"`
	} `yaml:"output"`
}

Config is a loaded .nasc/config.yaml. Every field is optional.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the zero-config defaults.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads config from path, returning defaults when it is absent.

type Field

type Field struct {
	Type      string   `yaml:"type"`
	Required  bool     `yaml:"required"`
	Derive    string   `yaml:"derive"`
	Enum      []string `yaml:"enum"`
	MinLength int      `yaml:"min_length"`
	MaxLength int      `yaml:"max_length"`
	Items     string   `yaml:"items"`
}

Field is one declared frontmatter field.

type Rule

type Rule struct {
	Name     string `yaml:"name"`
	When     string `yaml:"when"`
	Assert   string `yaml:"assert"`
	Severity string `yaml:"severity"`
	Message  string `yaml:"message"`
}

Rule is one custom validation rule.

type Schema

type Schema struct {
	Version    int
	Fields     map[string]Field
	FieldOrder []string
	Rules      []Rule
}

Schema is a loaded .nasc/schema.yaml.

func Load

func Load(path string) (*Schema, error)

Load reads and parses a schema file.

func Parse

func Parse(data []byte) (*Schema, error)

Parse decodes schema bytes, preserving field declaration order.

Jump to

Keyboard shortcuts

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