-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Milestone
Description
What steps will reproduce the problem? Run this program: package main import ( "fmt" "os" "text/template" ) type Foo struct { } func (foo Foo) Greeting() string { return "Hello" } type Bar struct { Foo } func main() { t := template.Must(template.New("").Parse("{{.Greeting}}\n{{.Foo.Greeting}}\n")) var bar Bar var unnamed struct{ Foo } if err := t.Execute(os.Stdout, bar); err != nil { fmt.Println(err) } fmt.Println("===========") fmt.Println(bar.Greeting()) fmt.Println(unnamed.Greeting()) fmt.Println("===========") if err := t.Execute(os.Stdout, unnamed); err != nil { fmt.Println(err) } } What is the expected output? Hello Hello =========== Hello Hello =========== Hello Hello What do you see instead? Hello Hello =========== Hello Hello =========== template: :1: can't evaluate field Greeting in type struct { main.Foo } Which compiler are you using (5g, 6g, 8g, gccgo)? 6g Which operating system are you using? Linux Which revision are you using? (hg identify) 96bd78e7d35e weekly/weekly.2012-02-22 Please provide any additional information below.