Use a single line for slice encoding (#119)
This commit is contained in:
committed by
Thomas Pelletier
parent
ce7be745f0
commit
017119f7a7
+1
-1
@@ -646,7 +646,7 @@ func TestToTomlValue(t *testing.T) {
|
||||
{time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC),
|
||||
"1979-05-27T07:32:00Z"},
|
||||
{[]interface{}{"gamma", "delta"},
|
||||
"[\n \"gamma\",\n \"delta\",\n]"},
|
||||
"[\"gamma\",\"delta\"]"},
|
||||
{nil, ""},
|
||||
} {
|
||||
result := toTomlValue(item.Value, 0)
|
||||
|
||||
@@ -79,11 +79,11 @@ func toTomlValue(item interface{}, indent int) string {
|
||||
case time.Time:
|
||||
return tab + value.Format(time.RFC3339)
|
||||
case []interface{}:
|
||||
result := tab + "[\n"
|
||||
values := []string{}
|
||||
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:
|
||||
return ""
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user