You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: template.go
    path of file: ./repos/grafana/pkg/util/errutil
    
    the code of the file until where you have to start completion: package errutil

import (
	"bytes"
	"fmt"
	"text/template"
)

// Template is an extended Base for when using templating to construct
// error messages.
type Template struct {
	Base           Base
	logTemplate    *template.Template
	publicTemplate *te
    
func (t Template) Build(data TemplateData) error {
	if t.logTemplate == nil {
		return fmt.Errorf("cannot initialize error using missing template")
	}

	buf := bytes.Buffer{}
	err := t.logTemplate.Execute(&buf, data)
	if err != nil {
		return err
	}

	pubBuf := bytes.Buffer{}
	if t.publicTemplate != nil {
		err := t.publicTemplate.Execute(&pubBuf, TemplateData{Public: data.Public})
		if err != nil {
			return err
		}
	}

	e := t.Base.Errorf("%s", buf.String())
	e.PublicMessage = pubBuf.String()
	e.PublicPayload = data.Public
	e.Underlying = data.Error

	return e
}