MCPcopy
hub / github.com/grafana/tempo / String

Method String

tools/chloggen/internal/chlog/summary.go:106–133  ·  view source on GitHub ↗

String renders the summary using the provided template.

(summaryTemplate string)

Source from the content-addressed store, hash-verified

104
105// String renders the summary using the provided template.
106func (s summary) String(summaryTemplate string) (string, error) {
107 var tmpl *template.Template
108 var err error
109
110 if summaryTemplate != "" {
111 tmpl, err = template.
112 New(filepath.Base(summaryTemplate)).
113 Funcs(TemplateFuncMap()).
114 Option("missingkey=error").
115 ParseFiles(summaryTemplate)
116 } else {
117 tmpl, err = template.
118 New("summary.tmpl").
119 Funcs(TemplateFuncMap()).
120 Option("missingkey=error").
121 Parse(string(defaultTmpl))
122 }
123 if err != nil {
124 return "", err
125 }
126
127 buf := bytes.Buffer{}
128 if err := tmpl.Execute(&buf, s); err != nil {
129 return "", fmt.Errorf("failed executing template: %w", err)
130 }
131
132 return buf.String(), nil
133}

Callers 3

GenerateSummaryFunction · 0.95
TestEntryFunction · 0.45
updateCmdFunction · 0.45

Calls 2

TemplateFuncMapFunction · 0.85
ParseMethod · 0.65

Tested by 1

TestEntryFunction · 0.36