func TemplateString(src string, outBuf *bytes.Buffer, vars map[string]interface{}) error {
	log.Logger.Tracef("Rendering template in '%s' with vars: %#v", src, vars)
	rendered, err := RenderTemplate(src, vars)
	if err != nil {
		return errors.WithStack(err)
	}
	_, err = outBuf.Write([]byte(rendered))
	if err != nil {
		return errors.WithStack(err)
	}
	log.Logger.Tracef("Successfully rendered input template: %s\n to\n %s",
		src, rendered)
	return nil
}
Renders a template into a buffer
package templater
import (
	"bytes"
	"github.com/Masterminds/sprig"
	"github.com/pkg/errors"
	"github.com/sugarkube/sugarkube/internal/pkg/log"
	"io/ioutil"
	"os"
	"text/template"
)
func RenderTemplate(inputTemplate string, vars map[string]interface{}) (string, error) {
	tpl := template.Must(
		template.New("gotpl").Funcs(
			sprig.TxtFuncMap()).Funcs(CustomFunctions).Parse(inputTemplate))
	buf := bytes.NewBuffer(nil)
	err := tpl.Execute(buf, vars)
	if err != nil {
		return "", errors.Wrapf(err, "Error executing template %s with vars %#v", inputTemplate, vars)
	}
	return buf.String(), nil
}
func TemplateFile(src string, outBuf *bytes.Buffer, vars map[string]interface{}) error {
	if _, err := os.Stat(src); err != nil {
		return errors.Wrapf(err, "Source template '%s' doesn't exist", src)
	}
	srcTemplate, err := ioutil.ReadFile(src)
	if err != nil {
		return errors.Wrapf(err, "Error reading source template file %s", src)
	}
	return TemplateString(string(srcTemplate[:]), outBuf, vars)
}