|
|
@ -45,6 +45,14 @@ func writeFieldsTo(w io.Writer, fields []Field, nl string) (int64, error) { |
|
|
|
return int64(written), nil |
|
|
|
return int64(written), nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String generates a string output for "%s"
|
|
|
|
|
|
|
|
func (field Field) String() string { |
|
|
|
|
|
|
|
var buf bytes.Buffer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_, _ = writeFieldsTo(&buf, []Field{field}, WriteNewLine) |
|
|
|
|
|
|
|
return buf.String() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func writeSectionToBuffer(w *bytes.Buffer, sec *Section, nl string) int { |
|
|
|
func writeSectionToBuffer(w *bytes.Buffer, sec *Section, nl string) int { |
|
|
|
var written, n int |
|
|
|
var written, n int |
|
|
|
|
|
|
|
|
|
|
@ -74,6 +82,14 @@ func writeSectionToBuffer(w *bytes.Buffer, sec *Section, nl string) int { |
|
|
|
return written + int(n64) |
|
|
|
return written + int(n64) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// String generates a string output for "%s"
|
|
|
|
|
|
|
|
func (sec *Section) String() string { |
|
|
|
|
|
|
|
var buf bytes.Buffer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = writeSectionToBuffer(&buf, sec, WriteNewLine) |
|
|
|
|
|
|
|
return buf.String() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// WriteTo writes a INI representation of the document
|
|
|
|
// WriteTo writes a INI representation of the document
|
|
|
|
// onto the provided writer.
|
|
|
|
// onto the provided writer.
|
|
|
|
func (doc *Document) WriteTo(w io.Writer) (int64, error) { |
|
|
|
func (doc *Document) WriteTo(w io.Writer) (int64, error) { |
|
|
@ -81,7 +97,7 @@ func (doc *Document) WriteTo(w io.Writer) (int64, error) { |
|
|
|
return buf.WriteTo(w) |
|
|
|
return buf.WriteTo(w) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GoString generates a string output for "%s"
|
|
|
|
// String generates a string output for "%s"
|
|
|
|
func (doc *Document) String() string { |
|
|
|
func (doc *Document) String() string { |
|
|
|
buf := doc.AsBuffer(WriteNewLine) |
|
|
|
buf := doc.AsBuffer(WriteNewLine) |
|
|
|
return buf.String() |
|
|
|
return buf.String() |
|
|
|