package example_test import ( "bytes" "fmt" "log" "text/template" ) func ExampleTemplateCalculator() { funcMap := template.FuncMap{ "add": func(a, b int) int { return a + b }, "sub": func(a, b int) int { return a - b }, "mul": func(a, b int) int { return a * b }, "div": func(a, b int) int { return a / b }, } var buf bytes.Buffer tp := template.Must(template.New("calculator").Funcs(funcMap).Parse("