Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal returns the TOML encoding of v.
Struct values encode as TOML. Each exported struct field becomes a field of the TOML structure unless
- the field's tag is "-", or
- the field is empty and its tag specifies the "omitempty" option.
The "toml" key in the struct field's tag value is the key name, followed by an optional comma and options. Examples:
// Field is ignored by this package. Field int `toml:"-"` // Field appears in TOML as key "myName". Field int `toml:"myName"` // Field appears in TOML as key "myName" and the field is omitted from the // result of encoding if its value is empty. Field int `toml:"myName,omitempty"` // Field appears in TOML as key "field", but the field is skipped if // empty. // Note the leading comma. Field int `toml:",omitempty"`
func Unmarshal ¶
Unmarshal parses the TOML data and stores the result in the value pointed to by v.
Unmarshal will mapped to v that according to following rules:
TOML strings to string TOML integers to any int type TOML floats to float32 or float64 TOML booleans to bool TOML datetimes to time.Time TOML arrays to any type of slice or []interface{} TOML tables to struct TOML array of tables to slice of struct
func UnmarshalTable ¶
UnmarshalTable applies the contents of an ast.Table to the value pointed at by v.
UnmarshalTable will mapped to v that according to following rules:
TOML strings to string TOML integers to any int type TOML floats to float32 or float64 TOML booleans to bool TOML datetimes to time.Time TOML arrays to any type of slice or []interface{} TOML tables to struct TOML array of tables to slice of struct
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes TOML from an input stream.
func NewDecoder ¶
NewDecoder returns a new Decoder that reads from r. Note that it reads all from r before parsing it.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
A Encoder writes TOML to an output stream.
func NewEncoder ¶
NewEncoder returns a new Encoder that writes to w.
type Marshaler ¶
Marshaler is the interface implemented by objects that can marshal themshelves into valid TOML.
type Unmarshaler ¶
Unmarshaler is the interface implemented by objects that can unmarshal a TOML description of themselves. The input can be assumed to be a valid encoding of a TOML value. UnmarshalJSON must copy the TOML data if it wishes to retain the data after returning.