Use a single line for slice encoding (#119)

This commit is contained in:
Christopher Mancini
2016-12-13 09:20:06 -05:00
committed by Thomas Pelletier
parent ce7be745f0
commit 017119f7a7
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -646,7 +646,7 @@ func TestToTomlValue(t *testing.T) {
{time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC), {time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC),
"1979-05-27T07:32:00Z"}, "1979-05-27T07:32:00Z"},
{[]interface{}{"gamma", "delta"}, {[]interface{}{"gamma", "delta"},
"[\n \"gamma\",\n \"delta\",\n]"}, "[\"gamma\",\"delta\"]"},
{nil, ""}, {nil, ""},
} { } {
result := toTomlValue(item.Value, 0) result := toTomlValue(item.Value, 0)
+3 -3
View File
@@ -79,11 +79,11 @@ func toTomlValue(item interface{}, indent int) string {
case time.Time: case time.Time:
return tab + value.Format(time.RFC3339) return tab + value.Format(time.RFC3339)
case []interface{}: case []interface{}:
result := tab + "[\n" values := []string{}
for _, item := range value { for _, item := range value {
result += toTomlValue(item, indent+2) + ",\n" values = append(values, toTomlValue(item, 0))
} }
return result + tab + "]" return "[" + strings.Join(values, ",") + "]"
case nil: case nil:
return "" return ""
default: default: