tomlwire

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tomlwire provides bounded, strict TOML document decoding and deterministic encoding.

TOML duplicate keys and malformed trailing text are always rejected. Datetime values use time.Time and TOML local date/time types according to the underlying decoder. Numeric conversions reject overflow and precision loss. TOML is not included in wire.DetectFormat because arbitrary text cannot be identified reliably.

Index

Constants

View Source
const DefaultMaxBytes int64 = 1 << 20

DefaultMaxBytes is the default maximum TOML document size.

Variables

View Source
var ErrPayloadTooLarge = errors.New("payload exceeds size limit")

ErrPayloadTooLarge identifies TOML documents over the configured limit.

Functions

func Decode

func Decode(payload []byte, target any, options DecodeOptions) error

Decode parses one complete TOML document into target.

func DecodeReader

func DecodeReader(reader io.Reader, target any, options DecodeOptions) error

DecodeReader reads a bounded stream and parses one complete TOML document.

func Encode

func Encode(value any, options EncodeOptions) ([]byte, error)

Encode serializes value deterministically with lexically ordered map keys.

func EncodeWriter

func EncodeWriter(writer io.Writer, value any, options EncodeOptions) error

EncodeWriter serializes value and writes one complete TOML document.

Types

type DecodeOptions

type DecodeOptions struct {
	MaxBytes              int64
	DisallowUnknownFields bool
}

DecodeOptions controls TOML decoding and schema strictness.

type EncodeOptions

type EncodeOptions struct {
	MaxBytes int64
	Indent   string
}

EncodeOptions controls TOML serialization. Indent may contain only spaces and tabs; the default is two spaces.

Jump to

Keyboard shortcuts

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