Configuration Language

Native language reference

ConstructMeaning
config_version 1One nonnegative integer at document root; omitted means legacy v0. Applications reject unsupported versions.
section service … endNamed section. Nesting and duplicate section names are rejected.
section remote westNamed instance; a schema may mark remote as repeated.
endpoint https://example.testEntry key plus literal. Duplicate keys within a section fail.
label "two words"Go-style quoted string with escapes such as \n, \", \\, \x00.
from_file(from_env(FILE))Recursive call; whitespace around arguments/delimiters is allowed.
from_json_file(config.json, .auth.token)Multiple arguments; dotted object lookup, not a query language.
# user note / ## schema docsPersisted ownership distinction for versioned v1+ files.

Comments occupy whole lines; inline # is not a comment delimiter. Indentation does not affect meaning. Useful blank lines and ordering are retained. Unknown fields/sections are ordinary nodes, not silently discarded. A legacy key with no value is not an override; use "" for an explicit empty string. Quote punctuation inside call arguments. A top-level bare comma remains literal for compatibility. Canonical formatting may change unnecessary quoting but preserves expressions.

SourceArguments and results
literalImplicit constant; string or exact []byte.
from_env(NAME)Name resolves as string; missing is an error, present empty is valid. String/[]byte results.
from_file(path)Path resolves as string. Exact string/[]byte, no trimming.
from_env_file(NAME)Compatibility alias; prefer nested file-from-env for new declarations.
from_json_file(path, .object.key)File path/selector resolve as strings; selected JSON values resolve as string/[]byte.

Register application declarers with registry.Register(name, resultTypeExample, resolver). Duplicate name/type registrations fail; the same name can support different types. Unknown names and unsupported requested types fail explicitly. Outer resolvers choose argument types; the parser needs no changes.

Defaults, examples, comments, and evolution

For example, a credential field can have no Default but have an Example from_file(from_env(CREDENTIAL_FILE)). Seed() leaves the field absent; Sample() emits an inactive ## credential from_file(...) illustration. Enrich() does not activate that example. Conversely, Default: Literal{"3"} for retries inserts an active value when missing. Explicit values always win over a changed schema default. Managed documentation is associated with fields and section blocks; user comments never become schema property merely because their prose resembles documentation.

Schema declares Version and ordered Sections. SectionDefinition gives Name, GoName/GoType, Documentation, Fields, Repeated and ExampleNames. Field carries Key, GoName/GoType, Default, Examples, Documentation, Required, Sensitive, InputOnly, RuntimeOnly, Deprecated, Policy and legacy Environment fallback metadata. Deprecated suppresses new sample/enrichment entries; InputOnly additionally blocks normal editing/runtime targets. Required checks missing declarations, not arbitrary application-specific value validation. Sensitive is inspection/error policy, not encryption at rest. Applications must validate their domain constraints after binding.