pelletier / go-toml

Go library for the TOML file format
https://github.com/pelletier/go-toml
Other
1.69k stars 206 forks source link

Encode: fix inline table first key value whitespace #837

Closed cuonglm closed 1 year ago

cuonglm commented 1 year ago

When encoding table inline, we should not apply ident. Otherwise, the key-value will be right align.

For example, this following data:

x := map[string][]map[string]string{
    "one": []map[string]string{
        {"0": "0"},
        {"1": "1"},
    },
}

will be encoded as:

one = [
  {  0 = '0'},
  {  1 = '1'}
]

This PR makes is to be encoded as:

one = [
  {0 = '0'},
  {1 = '1'}
]
pelletier commented 1 year ago

Looks good, thank you for the patch! Sorry it took me a while to find time to review.