config

package
v0.80.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config provides the @config and @config.load directives that populate meta["config"], which OnPreprocess forwards to the compiler as a compile-time key-value map.

Typical use:

@config:strict=true
@config {
  retries: 3       :cli="r,retries"
  timeout: "10s"   :cli="t"
}
@config.load:path="nexss.yml"

Index

Constants

View Source
const ID = "config"

Variables

View Source
var ConfigDirective = compiler.Directive{
	Name:        "config",
	Example:     "@config:strict=true\n@config {\n  retries: 3 :cli=\"r\"\n}",
	Handler:     handleConfig,
	OpaqueBlock: true,
}

ConfigDirective parses both the single-line form `@config:key=value` and the block form `@config { key: value, ... }`. Each pair is written to meta["config"] under its key.

View Source
var ConfigLoadDirective = compiler.Directive{
	Name:    "config.load",
	Example: `@config.load:path="nexss.yml"`,
	Handler: handleConfigLoad,
}

ConfigLoadDirective parses `@config.load:path="file.yml" [prefix="x"]` and flattens the loaded document into meta["config"], joining nested keys with dots.

Functions

func Bundle

func Bundle(_ map[string]string) compiler.Bundle

func DecodeFile added in v0.59.0

func DecodeFile(data []byte, ext string) (map[string]any, error)

DecodeFile dispatches by extension: .json → encoding/json, .toml → the minimal TOML parser, and .yaml/.yml → the registered YAML loader from extensions/config_yaml. It exposes structured values to runtime extensions without changing compile-time @config.load semantics.

func RegisterYAMLLoader added in v0.14.0

func RegisterYAMLLoader(fn func([]byte) (map[string]any, error))

RegisterYAMLLoader installs a YAML decoder. Called from the config_yaml bundle's init. Idempotent; later registrations win.

Types

This section is empty.

Jump to

Keyboard shortcuts

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