Fix build error
This commit is contained in:
parent
8f82318cce
commit
a82d80cf7f
37
ini.go
37
ini.go
|
@ -96,7 +96,7 @@ type Parser struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempts to write `entries` to `writer`, returning any error that occured during writing.
|
// Attempts to write `entries` to `writer`, returning any error that occured during writing.
|
||||||
func Write(writer io.Writer, entries []Entry) error {
|
func Write(writer io.StringWriter, entries []Entry) error {
|
||||||
// TODO: Not happy with this solution to writing files, needs more revision.
|
// TODO: Not happy with this solution to writing files, needs more revision.
|
||||||
var section = ""
|
var section = ""
|
||||||
|
|
||||||
|
@ -104,16 +104,37 @@ func Write(writer io.Writer, entries []Entry) error {
|
||||||
if entry.Section != section {
|
if entry.Section != section {
|
||||||
section = entry.Section
|
section = entry.Section
|
||||||
|
|
||||||
writer.Write([]byte{'['})
|
if _, writeError := writer.WriteString("["); writeError != nil {
|
||||||
writer.Write([]byte(entry.Section))
|
return writeError
|
||||||
writer.Write([]byte{']', '\n'})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Write([]byte(entry.Key))
|
if _, writeError := writer.WriteString(entry.Section); writeError != nil {
|
||||||
writer.Write([]byte{' ', '=', ' '})
|
return writeError
|
||||||
writer.Write([]byte(entry.Value))
|
|
||||||
writer.Write([]byte{'\n'})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, writeError := writer.WriteString("]"); writeError != nil {
|
||||||
|
return writeError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, writeError := writer.WriteString(entry.Key); writeError != nil {
|
||||||
|
return writeError
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, writeError := writer.WriteString(" = "); writeError != nil {
|
||||||
|
return writeError
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, writeError := writer.WriteString(entry.Value); writeError != nil {
|
||||||
|
return writeError
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, writeError := writer.WriteString("\n"); writeError != nil {
|
||||||
|
return writeError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string with the the outer-most quotes surrounding `s` trimmed, should they exist.
|
// Returns a string with the the outer-most quotes surrounding `s` trimmed, should they exist.
|
||||||
|
|
Loading…
Reference in New Issue