-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
Milestone
Description
What steps will reproduce the problem?
1. go run
package main
import (
"fmt"
"os"
"strings"
"text/template"
)
func T(s string) string {
return strings.Replace(s, "o", "a", -1)
}
type S struct {
Filter func(string) string
Name string
}
const tpl = `{{ .Filter .Name }}`
var t = template.Must(template.New("t").Parse(tpl))
func main() {
s := S{Filter: T, Name: "toto"}
err := t.Execute(os.Stdout, s)
if err != nil {
fmt.Println(err)
}
}
What is the expected output? What do you see instead?
Expected:
tata
Got:
template: t:1:3: executing "t" at <.Filter>: Filter has arguments but
cannot be invoked as function
go version devel +ea15e7ed6d72 Sun Dec 09 03:59:33 2012 -0500