Documentation
¶
Index ¶
- Constants
- func ParseTOML(src []byte) (*Table, []Diagnostic, error)
- type Diagnostic
- type Severity
- type SyntaxError
- type Table
- func (t *Table) Array(key string) ([]*Table, bool)
- func (t *Table) ArrayKeys() []string
- func (t *Table) Get(key string) (Value, bool)
- func (t *Table) Keys() []string
- func (t *Table) Line() int
- func (t *Table) Name() string
- func (t *Table) Qualify(key string) string
- func (t *Table) Sub(key string) (*Table, bool)
- func (t *Table) SubTables() []string
- type Value
- type ValueKind
Constants ¶
const ( SeverityWarning = diag.SeverityWarning SeverityError = diag.SeverityError )
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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 ¶
Array returns the elements of an array of tables ([[key]]), in document 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.