Make multi-line arrays always use trailing commas (#217)

This makes ArraysWithOneElementPerLine output arrays with commas after every element.

```
A = [1,2,3]
```

Now becomes:

```
A = [
  1,
  2,
  3,
]
```
This commit is contained in:
Chris
2018-02-28 15:36:31 -08:00
committed by Thomas Pelletier
parent acdc450948
commit 05bcc0fb0d
3 changed files with 4 additions and 6 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ func (e *Encoder) QuoteMapKeys(v bool) *Encoder {
// A = [
// 1,
// 2,
// 3
// 3,
// ]
func (e *Encoder) ArraysWithOneElementPerLine(v bool) *Encoder {
e.arraysOneElementPerLine = v
+1 -1
View File
@@ -775,7 +775,7 @@ func TestMarshalArrayOnePerLine(t *testing.T) {
B = [
1,
2,
3
3,
]
C = [1]
`)
+2 -4
View File
@@ -91,12 +91,10 @@ func tomlValueStringRepresentation(v interface{}, indent string, arraysOneElemen
stringBuffer.WriteString("[\n")
for i, value := range values {
for _, value := range values {
stringBuffer.WriteString(valueIndent)
stringBuffer.WriteString(value)
if i != len(values)-1 {
stringBuffer.WriteString(`,`)
}
stringBuffer.WriteString(`,`)
stringBuffer.WriteString("\n")
}