Fix writespacing in writing function

This commit is contained in:
kayomn 2022-12-20 23:26:38 +00:00
parent a82d80cf7f
commit 8a897dbd24
1 changed files with 4 additions and 4 deletions

8
ini.go
View File

@ -102,9 +102,7 @@ func Write(writer io.StringWriter, entries []Entry) error {
for _, entry := range entries { for _, entry := range entries {
if entry.Section != section { if entry.Section != section {
section = entry.Section if _, writeError := writer.WriteString("\n["); writeError != nil {
if _, writeError := writer.WriteString("["); writeError != nil {
return writeError return writeError
} }
@ -112,9 +110,11 @@ func Write(writer io.StringWriter, entries []Entry) error {
return writeError return writeError
} }
if _, writeError := writer.WriteString("]"); writeError != nil { if _, writeError := writer.WriteString("]\n"); writeError != nil {
return writeError return writeError
} }
section = entry.Section
} }
if _, writeError := writer.WriteString(entry.Key); writeError != nil { if _, writeError := writer.WriteString(entry.Key); writeError != nil {