github.com/gmemcc/yaegi@v0.12.1-0.20221128122509-aa99124c5d16/_test/issue-1179.go (about)

     1  package main
     2  
     3  type I interface {
     4  	F()
     5  }
     6  
     7  type T struct {
     8  	Name string
     9  }
    10  
    11  func (t *T) F() { println("in F", t.Name) }
    12  
    13  func NewI(s string) I { return newT(s) }
    14  
    15  func newT(s string) *T { return &T{s} }
    16  
    17  func main() {
    18  	i := NewI("test")
    19  	i.F()
    20  }
    21  
    22  // Output:
    23  // in F test