toml

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package toml is the "toml" 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

View Source
var Module = std.Module{
	Name: "toml",
	WASM: true,
	Path: "encoding/toml",
	Doc:  "TOML parse and stringify (TOML 1.0 via pelletier/go-toml/v2).",
	Methods: []std.Method{
		{
			Name:    "parse",
			Doc:     "Decode a TOML document into a value (tables become maps, arrays become lists, plus strings, numbers, bools, and datetimes); errors on invalid input.",
			Args:    []std.Arg{{Name: "source", Type: std.TypeString}},
			Returns: []std.Ret{{Type: std.TypeAny}},
			Raises:  true,
			Impl:    TOMLParse,
		},
		{
			Name:    "stringify",
			Doc:     "Encode a value to a TOML string; the top level must be a table/map, as TOML requires. Errors on unencodable input.",
			Args:    []std.Arg{{Name: "value", Type: std.TypeAny}},
			Returns: []std.Ret{{Type: std.TypeString}},
			Raises:  true,
			Impl:    TOMLStringify,
		},
	},
}

Module is the "toml" host module: TOML parse and stringify via pelletier/go-toml/v2. It mirrors the json and yaml modules so a magusfile can read a value out of a pyproject.toml / Cargo.toml the same way it reads package.json.

Functions

func Modules

func Modules() []std.Module

Modules returns this directory's contribution to the encoding module set. See std/encoding/register.go: it aggregates every leaf's Modules() into one slice, which is how a module here reaches std.All()'s callers without std importing this package to collect it.

func TOMLParse

func TOMLParse(_ context.Context, source string) (any, error)

TOMLParse decodes source as TOML. Unmarshalling into interface{} yields map[string]interface{} for tables (a TOML document is always a top-level table), so the result is safe to pass across the Buzz boundary.

func TOMLStringify

func TOMLStringify(_ context.Context, value any) (string, error)

TOMLStringify encodes value to a TOML string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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