tomlutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 11 Imported by: ? modules, 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

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedType = errors.New("toml: unsupported value type")

Error of a value TOML has no form for, wrapped with the value's Go type

Functions

func Decode

func Decode[T ~string | ~[]byte](data T) (map[string]any, error)

Tables of a TOML document as nested maps, a *DecodeError when the text is not TOML; integers come back as int64, floats as float64, offset date-times as time.Time, local dates and times as toml.LocalDate, toml.LocalTime and toml.LocalDateTime, arrays as []any

func DecodeOrdered

func DecodeOrdered[T ~string | ~[]byte](data T) (*jsonutil.Object, error)

Document as Decode reads it with every table, nested ones and those inside arrays included, an ordered object keeping the key order of the text

func Encode

func Encode(doc *jsonutil.Object) (string, error)

Ordered document as TOML text: each table's plain values first, then its subtables under [header] lines in key order, arrays one item per line indented by four spaces, an array of tables inline when every table fits on one line and as [[header]] tables otherwise; tables may be *jsonutil.Object or map[string]any (written in sorted key order), an error wrapping ErrUnsupportedType for a value of a type TOML has no form for, and an error for an integer past 64 signed bits or an offset date-time outside the years 0 to 9999

func FormatFloat

func FormatFloat(f float64, bits int) string

TOML float text of f as Encode writes it, bits 32 or 64 as for strconv.FormatFloat: reads back as the same value and as a float, inf and nan spelled as TOML has them

func FormatKey

func FormatKey(key string) string

TOML text of a key as Encode writes it: bare when it is nonempty and every byte is an ASCII letter, digit, dash or underscore, otherwise a quoted basic string

func FormatString

func FormatString(s string) string

TOML basic string of s as Encode writes it: quotes, backslashes and control characters escaped, tabs kept, invalid UTF-8 replaced by U+FFFD

Types

type DecodeError

type DecodeError struct {
	Line   int
	Column int
	Msg    string
	// contains filtered or unexported fields
}

Error of text that is not a TOML document, with the 1-based line and column reading stopped at, both zero when unknown

func (*DecodeError) Error

func (e *DecodeError) Error() string

The message after its position, as in toml: line 3, column 7: expected character =

func (*DecodeError) Unwrap

func (e *DecodeError) Unwrap() error

Error of the TOML library this one was made from, a *toml.DecodeError whose String shows the offending lines

Jump to

Keyboard shortcuts

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