diff --git a/cobra/cmd/helpers.go b/cobra/cmd/helpers.go index e7ae8085..d5ee9062 100644 --- a/cobra/cmd/helpers.go +++ b/cobra/cmd/helpers.go @@ -23,10 +23,6 @@ import ( "text/template" ) -var funcMap = template.FuncMap{ - "comment": commentifyString, -} - var projectPath string var cmdDirs = [...]string{"cmd", "cmds", "command", "commands"} @@ -87,8 +83,11 @@ func exists(path string) bool { return false } +var tmpl = template.New("").Funcs(template.FuncMap{"comment": commentifyString}) + func executeTemplate(tmplStr string, data interface{}) (string, error) { - tmpl, err := template.New("").Funcs(funcMap).Parse(tmplStr) + var err error + tmpl, err = tmpl.Parse(tmplStr) if err != nil { return "", err }