toml

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 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

View Source
const (
	SeverityWarning = diag.SeverityWarning
	SeverityError   = diag.SeverityError
)

Variables

This section is empty.

Functions

func ParseTOML

func ParseTOML(src []byte) (*Table, []Diagnostic, error)

ParseTOML returns the root table, the diagnostics for keys it deliberately skipped, and an error only for a grammar failure.

Types

type Diagnostic

type Diagnostic = diag.Diagnostic

Diagnostic and Severity are the shared report type (internal/diag), aliased so a caller of this package needs one import rather than two.

type Severity

type Severity = diag.Severity

Diagnostic and Severity are the shared report type (internal/diag), aliased so a caller of this package needs one import rather than two.

type SyntaxError

type SyntaxError struct {
	Line int
	Msg  string
}

SyntaxError is a structural failure: the parser cannot know where the remaining keys belong, so it stops.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table is a TOML table. It preserves key insertion order, which is what makes the unknown-key diagnostics deterministic: a map iteration would reorder the warnings between runs and turn a golden test into a flake.

func (*Table) Array

func (t *Table) Array(key string) ([]*Table, bool)

Array returns the elements of an array of tables ([[key]]), in document order.

func (*Table) ArrayKeys

func (t *Table) ArrayKeys() []string

ArrayKeys returns the names of the arrays of tables declared here.

func (*Table) Get

func (t *Table) Get(key string) (Value, bool)

Get returns the value written for key.

func (*Table) Keys

func (t *Table) Keys() []string

Keys returns the table's own keys in the order they were written.

func (*Table) Line

func (t *Table) Line() int

Line is the 1-based line of the table's header, 0 for the root table.

func (*Table) Name

func (t *Table) Name() string

Name is the dotted path of the table, empty for the root table.

func (*Table) Qualify

func (t *Table) Qualify(key string) string

Qualify renders a key with its table prefix, for a diagnostic that has to name where in the document the problem is.

func (*Table) Sub

func (t *Table) Sub(key string) (*Table, bool)

Sub returns the named sub-table.

func (*Table) SubTables

func (t *Table) SubTables() []string

SubTables returns the names of the table's sub-tables in written order.

type Value

type Value struct {
	Kind  ValueKind
	Str   string
	Bool  bool
	Int   int64
	Float float64
	Array []string
	// Line is the 1-based line the value was written on, so a diagnostic can
	// point the manifest author at it.
	Line int
}

Value is one parsed TOML scalar or string array. It is a tagged struct rather than an `any`, so a manifest reader that asks for the wrong type gets a diagnostic instead of a panic.

type ValueKind

type ValueKind uint8

ValueKind enumerates the value types listed above.

const (
	KindString ValueKind = iota
	KindBool
	KindInt
	KindStringArray
	KindFloat
)

Jump to

Keyboard shortcuts

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