package main import ( "fmt" "os" "text/template" ) type ( rssItem struct { Title string Link string } ) func genRSSBlog(blogDataSlice []blogData) { var rssItemSlice []rssItem for _, post := range blogDataSlice { rssItemSlice = append(rssItemSlice, rssItem{ Title: post.Title, Link: post.URL, }) } tpl, err := template.ParseFiles("templates/rss.xml.gotmpl") if err != nil { fmt.Printf("ERROR creating template: %s\n", err) } f, err := os.Create("html/en/blog/rss.xml.html") if err != nil { fmt.Printf("ERROR creating xml: %s\n", err) panic(1) } err = tpl.ExecuteTemplate(f, "rss.xml.gotmpl", rssItemSlice) if err != nil { fmt.Printf("ERROR executing template: %s\n", err) } } func genRSSBlogRecs(recList []blogRec) { tpl, err := template.ParseFiles("templates/blogrecs.xml.gotmpl") if err != nil { fmt.Printf("ERROR creating template: %s\n", err) } f, err := os.Create("html/en/blogrecs.xml.html") if err != nil { fmt.Printf("ERROR creating xml: %s\n", err) panic(1) } err = tpl.ExecuteTemplate(f, "blogrecs.xml.gotmpl", recList) if err != nil { fmt.Printf("ERROR executing template: %s\n", err) } }