Fix inline table first key value whitespace (#837)

Co-authored-by: Cuong Manh Le <cuong@windscribe.com>
This commit is contained in:
Cuong Manh Le
2023-02-01 18:00:09 +07:00
committed by GitHub
parent 58a592bbf8
commit 090cccf4ba
2 changed files with 22 additions and 1 deletions
+21
View File
@@ -1190,6 +1190,27 @@ func TestMarshalUint64Overflow(t *testing.T) {
require.Error(t, err)
}
func TestIndentWithInlineTable(t *testing.T) {
x := map[string][]map[string]string{
"one": []map[string]string{
{"0": "0"},
{"1": "1"},
},
}
expected := `one = [
{0 = '0'},
{1 = '1'}
]
`
var buf bytes.Buffer
enc := toml.NewEncoder(&buf)
enc.SetIndentTables(true)
enc.SetTablesInline(true)
enc.SetArraysMultiline(true)
require.NoError(t, enc.Encode(x))
assert.Equal(t, expected, buf.String())
}
func ExampleMarshal() {
type MyConfig struct {
Version int