Skip to content

Instantly share code, notes, and snippets.

@dbridges
Created May 13, 2019 17:44
Show Gist options
  • Save dbridges/6fee63da2733e825efcffb93f45dfaa9 to your computer and use it in GitHub Desktop.
Save dbridges/6fee63da2733e825efcffb93f45dfaa9 to your computer and use it in GitHub Desktop.
func loadTemplate() *template.Template {
templates, err := filepath.Glob("templates/*")
if err != nil {
log.Println(err)
}
t := template.Must(template.New("layout.go.html").ParseFiles(templates...))
return t
}
func main() {
// ...
t := loadTemplate()
writer := &strings.Builder{}
err := t.Execute(writer, feeds)
if err != nil {
log.Fatalln(err)
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment