Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: MarshalIndent output starts with a newline character #3354

Closed
jstemmer opened this issue Mar 19, 2012 · 6 comments
Closed

encoding/xml: MarshalIndent output starts with a newline character #3354

jstemmer opened this issue Mar 19, 2012 · 6 comments
Milestone

Comments

@jstemmer
Copy link
Contributor

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
@dsymonds
Copy link
Contributor

Comment 1:

That's still valid XML, right?

Labels changed: added priority-someday, packagechange, removed priority-triage.

@jstemmer
Copy link
Contributor Author

Comment 2:

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.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 3:

Labels changed: added priority-later, removed priority-someday.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Labels changed: added go1.1maybe.

@shivakumargn
Copy link
Contributor

Comment 5:

https://golang.org/cl/7288047

@rsc
Copy link
Contributor

rsc commented Feb 3, 2013

Comment 6:

This issue was closed by revision 848d10f.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants