Let discuss on template libraries, using {{range}} in multiple loop will slow down with HTML escaping and rendering to the template. Is there a better approach to escape Posts in one pass before rendering with html/template?
Forum.go
import("html/template")
var tmpl = template.Must(template.ParseFiles("index.html"))
type Thread struct {
Title string
}
type ListThreads struct {
Threads []*Thread
}
Posts := make([]*Thread, 30)
p := ListThreads{Posts}
tmpl.Execute(w, &p)
Template.html
{{ range .Threads }}
{{ .Title }}
{{ end }}
I also considerig Jet Template for fast on the fly rendering for speed improvement is worth a try?