Skip to content

Instantly share code, notes, and snippets.

@softwarebygabe
Last active June 22, 2019 19:43
Show Gist options
  • Save softwarebygabe/2de77aae5b04df43206ddcde50f9ae79 to your computer and use it in GitHub Desktop.
Save softwarebygabe/2de77aae5b04df43206ddcde50f9ae79 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/xml"
"fmt"
)
type Cat struct {
Name string
Breed string
Age int
}
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

<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