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
When the comment tag of a struct that is marshalled contains newline characters (\n), it is encoded into an invalid TOML document.
In the encoded version only the first line of the comment starts with the comment character (#).
All other lines of the comments are missing it.
Using \n in comment tags generated valid multiline comments in v1.
How To Reproduce
package main
import (
"fmt""github.com/pelletier/go-toml/v2"
)
funcmain() {
typecfgstruct {
Namestring`comment:"This is a multiline comment.\nThis is line 2."`
}
out, err:=toml.Marshal(&cfg{})
iferr!=nil {
panic(err)
}
fmt.Println(string(out))
}
Generated TOML document:
# This is a multiline comment.This is line 2.Name = ''
Expected behavior
I expected the following generated TOML document:
# This is a multiline comment.
# This is line 2.
Name = ''
Versions
go-toml: v2.0.0
go: 1.18.1
operating system: Linux
The text was updated successfully, but these errors were encountered:
Describe the bug
When the
comment
tag of a struct that is marshalled contains newline characters (\n
), it is encoded into an invalid TOML document.In the encoded version only the first line of the comment starts with the comment character (
#
).All other lines of the comments are missing it.
Using
\n
in comment tags generated valid multiline comments in v1.How To Reproduce
Generated TOML document:
Expected behavior
I expected the following generated TOML document:
Versions
The text was updated successfully, but these errors were encountered: