Created
June 22, 2019 20:19
-
-
Save softwarebygabe/cbd7c7a9d2f6be5733650794e58b9cf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/xml" | |
"fmt" | |
) | |
type Cat struct { | |
XMLName xml.Name `xml:"cat"` | |
Name string `xml:"name,omitempty"` | |
Breed string `xml:"-"` | |
Age int `xml:"age,omitempty"` | |
} | |
func main() { | |
cat := Cat{ | |
Name: "Olive", | |
Breed: "Oriental Shorthair", | |
} | |
bytes, err := xml.MarshalIndent(cat, "", " ") | |
if err != nil { | |
panic(err) | |
} | |
fmt.Println(string(bytes)) | |
} |
Author
softwarebygabe
commented
Jun 22, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment