package main import ( "log" "os" //"text/template" "html/template" ) type Data struct { MyTitle string Lst []int Thing interface{} } func main() { var err error //tpl, err := template.ParseFiles("tpl.html") tpl := template.New("tpl.html") tpl = tpl.Funcs(template.FuncMap{ "myFunc": func(s string) string { return s + s }, }) tpl, err = tpl.ParseFiles("tpl.html") if err != nil { log.Fatalln(err) } /* data := map[string]string{ "myTitle": "plop", } data := []int{1, 2, 3} data := map[string]interface{}{ "myTitle": "plop", "lst": []int{1, 2, 3}, } */ data := Data{ //"plop", "", []int{1, 2, 3}, template.HTML(""), } err = tpl.Execute(os.Stdout, data) if err != nil { log.Fatalln(err) } }