Skip to content

Instantly share code, notes, and snippets.

@EtienneR
Last active August 29, 2015 14:27
Show Gist options
  • Save EtienneR/1f8f089394d4cea3b4dd to your computer and use it in GitHub Desktop.
Save EtienneR/1f8f089394d4cea3b4dd to your computer and use it in GitHub Desktop.
RSS feed part1
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)
}
}
<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