github.com/HaHadaxigua/yaegi@v1.0.1/_test/method36.go (about) 1 package main 2 3 type I interface{ Hello() } 4 5 type T struct{ Name string } 6 7 func (t *T) Hello() { println("Hello", t.Name) } 8 9 type FT func(i I) 10 11 type ST struct{ Handler FT } 12 13 func newF() FT { 14 return func(i I) { 15 i.Hello() 16 } 17 } 18 19 func main() { 20 st := &ST{} 21 st.Handler = newF() 22 st.Handler(&T{"test"}) 23 } 24 25 // Output: 26 // Hello test