Skip to content

Instantly share code, notes, and snippets.

@dragonfax
Last active August 30, 2015 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragonfax/ca3ee45a0acf97820f58 to your computer and use it in GitHub Desktop.
Save dragonfax/ca3ee45a0acf97820f58 to your computer and use it in GitHub Desktop.
golang oddity, XML encode encodes double quote wrong.

The standard is for double quote (") to be encoded into " But golang seems to encode as the literal entity "

package main
import (
"encoding/xml"
"os"
)
func main() {
type Person struct {
FirstName string `xml:"name>first"`
}
v := &Person{FirstName: `"John"`}
enc := xml.NewEncoder(os.Stdout)
enc.Encode(v)
}
<Person><name><first>&#34;John&#34;</first></name></Person>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment