Skip to content

Instantly share code, notes, and snippets.

@softwarebygabe
Created June 22, 2019 19:54
Show Gist options
  • Save softwarebygabe/2561a3df9501d2fe54901d4de9a62409 to your computer and use it in GitHub Desktop.
Save softwarebygabe/2561a3df9501d2fe54901d4de9a62409 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/xml"
"fmt"
)
type Cat struct {
Name string `xml:"name"`
Breed string `xml:"breed"`
Age int `xml:"age"`
}
func main() {
cat := Cat{
Name: "Olive",
Breed: "Oriental Shorthair",
Age: 1,
}
bytes, err := xml.MarshalIndent(cat, "", " ")
if err != nil {
panic(err)
}
fmt.Println(string(bytes))
}
@softwarebygabe
Copy link
Author

softwarebygabe commented Jun 22, 2019

<Cat>
  <name>Olive</name>
  <breed>Oriental Shorthair</breed>
  <age>1</age>
</Cat>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment