我有我的模板,这些模板最初是在应用程序启动时解析的(显然是出于这样的速度原因)vartemplates=template.New("template")filepath.Walk("views",func(pathstring,infoos.FileInfo,errerror)error{ifstrings.HasSuffix(path,".html"){templates.ParseFiles(path)}returnnil})log.Println("TemplatesParsed")然后我将我的funcmap添加到它们自己的函数中(因为我需要请求对象,所以我可以像这样获取它们的s
我有我的模板,这些模板最初是在应用程序启动时解析的(显然是出于这样的速度原因)vartemplates=template.New("template")filepath.Walk("views",func(pathstring,infoos.FileInfo,errerror)error{ifstrings.HasSuffix(path,".html"){templates.ParseFiles(path)}returnnil})log.Println("TemplatesParsed")然后我将我的funcmap添加到它们自己的函数中(因为我需要请求对象,所以我可以像这样获取它们的s