这个问题在这里已经有了答案:Golangtemplates(andpassingfuncstotemplate)(2个答案)关闭4年前。我以这种方式呈现模板:funcrenderTemplate(...........){rt:=template.Must(template.ParseFiles(fmt.Sprintf("%s/%s",templatesPath,baseLayoutPath),fmt.Sprintf("%s/%s",templatesPath,tplName)))err:=rt.ExecuteTemplate(w,"base",nil)//[.............