+8
-4
@@ -54,8 +54,9 @@ func NewEncoder(w io.Writer) *Encoder {
|
|||||||
// inline tag:
|
// inline tag:
|
||||||
//
|
//
|
||||||
// MyField `inline:"true"`
|
// MyField `inline:"true"`
|
||||||
func (enc *Encoder) SetTablesInline(inline bool) {
|
func (enc *Encoder) SetTablesInline(inline bool) *Encoder {
|
||||||
enc.tablesInline = inline
|
enc.tablesInline = inline
|
||||||
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetArraysMultiline forces the encoder to emit all arrays with one element per
|
// SetArraysMultiline forces the encoder to emit all arrays with one element per
|
||||||
@@ -64,20 +65,23 @@ func (enc *Encoder) SetTablesInline(inline bool) {
|
|||||||
// This behavior can be controlled on an individual struct field basis with the multiline tag:
|
// This behavior can be controlled on an individual struct field basis with the multiline tag:
|
||||||
//
|
//
|
||||||
// MyField `multiline:"true"`
|
// MyField `multiline:"true"`
|
||||||
func (enc *Encoder) SetArraysMultiline(multiline bool) {
|
func (enc *Encoder) SetArraysMultiline(multiline bool) *Encoder {
|
||||||
enc.arraysMultiline = multiline
|
enc.arraysMultiline = multiline
|
||||||
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetIndentSymbol defines the string that should be used for indentation. The
|
// SetIndentSymbol defines the string that should be used for indentation. The
|
||||||
// provided string is repeated for each indentation level. Defaults to two
|
// provided string is repeated for each indentation level. Defaults to two
|
||||||
// spaces.
|
// spaces.
|
||||||
func (enc *Encoder) SetIndentSymbol(s string) {
|
func (enc *Encoder) SetIndentSymbol(s string) *Encoder {
|
||||||
enc.indentSymbol = s
|
enc.indentSymbol = s
|
||||||
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetIndentTables forces the encoder to intent tables and array tables.
|
// SetIndentTables forces the encoder to intent tables and array tables.
|
||||||
func (enc *Encoder) SetIndentTables(indent bool) {
|
func (enc *Encoder) SetIndentTables(indent bool) *Encoder {
|
||||||
enc.indentTables = indent
|
enc.indentTables = indent
|
||||||
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode writes a TOML representation of v to the stream.
|
// Encode writes a TOML representation of v to the stream.
|
||||||
|
|||||||
+1
-1
@@ -551,7 +551,7 @@ K = 42`,
|
|||||||
|
|
||||||
type flagsSetters []struct {
|
type flagsSetters []struct {
|
||||||
name string
|
name string
|
||||||
f func(enc *toml.Encoder, flag bool)
|
f func(enc *toml.Encoder, flag bool) *toml.Encoder
|
||||||
}
|
}
|
||||||
|
|
||||||
var allFlags = flagsSetters{
|
var allFlags = flagsSetters{
|
||||||
|
|||||||
+2
-1
@@ -48,8 +48,9 @@ func NewDecoder(r io.Reader) *Decoder {
|
|||||||
// that could not be set on the target value. In that case, the decoder returns
|
// that could not be set on the target value. In that case, the decoder returns
|
||||||
// a StrictMissingError that can be used to retrieve the individual errors as
|
// a StrictMissingError that can be used to retrieve the individual errors as
|
||||||
// well as generate a human readable description of the missing fields.
|
// well as generate a human readable description of the missing fields.
|
||||||
func (d *Decoder) SetStrict(strict bool) {
|
func (d *Decoder) SetStrict(strict bool) *Decoder {
|
||||||
d.strict = strict
|
d.strict = strict
|
||||||
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode the whole content of r into v.
|
// Decode the whole content of r into v.
|
||||||
|
|||||||
Reference in New Issue
Block a user