Documentation
¶
Overview ¶
Package ini is the "encoding/ini" host module. See std/encoding/register.go for why this and its eight siblings each get their own leaf package instead of living in std's flat root, and how this directory's Module reaches the rest of magus without std importing back down to collect it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = std.Module{ Name: "ini", WASM: true, Path: "encoding/ini", Doc: "INI/properties config parsing and rendering (.npmrc, .gitconfig, .editorconfig).", Methods: []std.Method{ { Name: "parse", Doc: "Parse INI text into {section: {key: value}}. Entries before the first [section] header are under the \"\" key, which is where a flat file like .npmrc puts everything. Values are always strings; a repeated key takes the last value.", Args: []std.Arg{{Name: "source", Type: std.TypeString}}, Returns: []std.Ret{{Type: std.TypeStringMapMap}}, Raises: true, Impl: INIParse, }, { Name: "stringify", Doc: "Render {section: {key: value}} back to INI text. The \"\" section is written first with no header, then the rest sorted by name with their keys sorted, so the output is byte-stable and diffs cleanly.", Args: []std.Arg{{Name: "sections", Type: std.TypeStringMapMap}}, Returns: []std.Ret{{Type: std.TypeString}}, Impl: INIStringify, }, }, }
Module is the "encoding/ini" host module: the key=value config format that has no standard and is everywhere anyway - .npmrc, .gitconfig, .editorconfig, setup.cfg, .flake8, most systemd units.
tools/audit.buzz is the reason this exists. It carries a `coolingHours` constant with the comment "mirrors minimum-release-age in each project's .npmrc ... restated as a duration because .npmrc is not a format Buzz reads" - a value duplicated by hand, in a second unit, that can drift from the file it mirrors. That is what a missing parser costs.
WHAT THIS PARSES, stated plainly because INI has no specification and every implementation draws the line somewhere different:
- `[section]` headers; entries before the first are under the "" key.
- `key = value` and `key=value`; surrounding whitespace is trimmed from both.
- `;` and `#` comment lines. A `#` INSIDE a value is kept, because a value is frequently a URL with a fragment and treating that as a comment silently truncates it.
- Quoted values ("..." or '...') have their quotes stripped, which is how a value with meaningful leading or trailing spaces is written.
- A repeated key takes the LAST value, matching how git and npm resolve one.
What it deliberately does NOT do: subsections (`[a "b"]` is one section named literally `a "b"`), multi-line continuations, or type inference. Every value is a string; a caller that wants a number parses it, which is the honest shape when the format itself has no types.
Functions ¶
func INIStringify ¶
INIStringify renders a section -> key -> value map back to INI text.
Types ¶
This section is empty.