Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 11c5ce70a6 | |||
| 16d52188f6 |
+17
-1
@@ -45,6 +45,14 @@ func writeFieldsTo(w io.Writer, fields []Field, nl string) (int64, error) {
|
||||
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 {
|
||||
var written, n int
|
||||
|
||||
@@ -74,6 +82,14 @@ func writeSectionToBuffer(w *bytes.Buffer, sec *Section, nl string) int {
|
||||
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
|
||||
// onto the provided writer.
|
||||
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)
|
||||
}
|
||||
|
||||
// GoString generates a string output for "%s"
|
||||
// String generates a string output for "%s"
|
||||
func (doc *Document) String() string {
|
||||
buf := doc.AsBuffer(WriteNewLine)
|
||||
return buf.String()
|
||||
|
||||
Reference in New Issue
Block a user