Documentation
¶
Index ¶
- Variables
- func Decode[T ~string | ~[]byte](data T) (map[string]any, error)
- func DecodeOrdered[T ~string | ~[]byte](data T) (*jsonutil.Object, error)
- func Encode(doc *jsonutil.Object) (string, error)
- func FormatFloat(f float64, bits int) string
- func FormatKey(key string) string
- func FormatString(s string) string
- type DecodeError
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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