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.
|
||||
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.
|
||||
var section = ""
|
||||
|
||||
|
@ -104,16 +104,37 @@ func Write(writer io.Writer, entries []Entry) error {
|
|||
if entry.Section != section {
|
||||
section = entry.Section
|
||||
|
||||
writer.Write([]byte{'['})
|
||||
writer.Write([]byte(entry.Section))
|
||||
writer.Write([]byte{']', '\n'})
|
||||
if _, writeError := writer.WriteString("["); writeError != nil {
|
||||
return writeError
|
||||
}
|
||||
|
||||
if _, writeError := writer.WriteString(entry.Section); writeError != nil {
|
||||
return writeError
|
||||
}
|
||||
|
||||
if _, writeError := writer.WriteString("]"); writeError != nil {
|
||||
return writeError
|
||||
}
|
||||
}
|
||||
|
||||
writer.Write([]byte(entry.Key))
|
||||
writer.Write([]byte{' ', '=', ' '})
|
||||
writer.Write([]byte(entry.Value))
|
||||
writer.Write([]byte{'\n'})
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue