You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Using the SetIndentTables(true) option does not correctly indent keys of arrays of custom types.
It does work correctly if the custom type is not a slice.
Example:
If I have some data structure a.b.c I expect the generated TOML to look like the following:
# comment A
[A]
# comment B
[A.B]
# comment C
[A.B.C]
Assuming c is an array I would expect the following:
# comment A
[A]
# comment B
[A.B]
# comment C
[[A.B.C]]
# Entry 1
[[A.B.C]]
# Entry 2
Instead, go-toml gives me something like the following:
# comment A
[A]
# comment B
[A.B]
# comment C
[[A.B.C]]
# Entry 1
[[A.B.C]]
# Entry 2
Expected behavior
I'm expecting the generated TOML to look like the following, correctly indenting layer1.layer2 with + and layer1.layer2.layer3 with two ++:
$ go run ./
# value comment
value = 'value'
# layer1 comment
[[layer1]]
+# value comment
+value = 'value'
+# layer2 comment
+[[layer1.layer2]]
++# value comment
++value = 'value'
++# layer3 comment
++[[layer1.layer2.layer3]]
+++# value comment
+++value = 'value'
+++# customType comment
+++[layer1.layer2.layer3.customType]
++++# value comment
++++value = 'value'
In practice, only the comments for layer1.layer2 and layer1.layer2.layer3 are indented, the keys are not:
$ go run ./
# value comment
value = 'value'
# layer1 comment
[[layer1]]
+# value comment
+value = 'value'
+# layer2 comment
[[layer1.layer2]]
++# value comment
++value = 'value'
++# layer3 comment
[[layer1.layer2.layer3]]
+++# value comment
+++value = 'value'
+++# customType comment
+++[layer1.layer2.layer3.customType]
++++# value comment
++++value = 'value'
Versions
go-toml: v2.2.0
go: 1.22.1
operating system: Linux
Additional context
Add any other context about the problem here that you think may help to diagnose.
The text was updated successfully, but these errors were encountered:
Describe the bug
Using the
SetIndentTables(true)
option does not correctly indent keys of arrays of custom types.It does work correctly if the custom type is not a slice.
Example:
If I have some data structure
a.b.c
I expect the generated TOML to look like the following:Assuming
c
is an array I would expect the following:Instead, go-toml gives me something like the following:
To Reproduce
Expected behavior
I'm expecting the generated TOML to look like the following, correctly indenting
layer1.layer2
with+
andlayer1.layer2.layer3
with two++
:In practice, only the comments for
layer1.layer2
andlayer1.layer2.layer3
are indented, the keys are not:Versions
Additional context
Add any other context about the problem here that you think may help to diagnose.
The text was updated successfully, but these errors were encountered: