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),
|
{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)
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user