Last active
August 29, 2015 14:27
-
-
Save EtienneR/1f8f089394d4cea3b4dd to your computer and use it in GitHub Desktop.
RSS feed part1
This file contains 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" | |
"os" | |
) | |
func main() { | |
type rss struct { | |
Version string `xml:"version,attr"` | |
Description string `xml:"channel>description"` | |
Link string `xml:"channel>link"` | |
Title string `xml:"channel>title"` | |
} | |
v := &rss{ | |
Version: "2.0", | |
Description: "My super website", | |
Link: "http://mywebsite.com", | |
Title: "Mywebsite", | |
} | |
enc := xml.NewEncoder(os.Stdout) | |
enc.Indent(" ", " ") | |
if err := enc.Encode(v); err != nil { | |
fmt.Printf("error: %v\n", err) | |
} | |
} |
This file contains 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
<rss version="2.0"> | |
<channel> | |
<description>My super website</description> | |
<link>http://mywebsite.com</link> | |
<title>Mywebsite</title> | |
</channel> | |
</rss> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment