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
The output of xml.MarshalIndent always starts with a newline character when the prefix
or indent parameters are non-empty. This results for example in an empty line between
the header and the rest of the xml document when used together with xml.Header.
What steps will reproduce the problem?
package main
import (
"encoding/xml"
"fmt"
)
func main() {
d, _ := xml.MarshalIndent("test", "", "\t")
fmt.Printf("%#v\n", string(d))
}
What is the expected output?
"<string>test</string>"
What do you see instead?
"\n<string>test</string>"
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
linux
Which revision are you using? (hg identify)
a216dfd16073 tip
The text was updated successfully, but these errors were encountered:
Yes, it's valid XML afaik. The reason for using MarshalIndent instead of Marshal was to
create a nicely formatted document, so this was a bit unexpected. Just a minor issue.
The text was updated successfully, but these errors were encountered: