github.com/traefik/yaegi@v0.15.1/_test/method5.go (about)

     1  package main
     2  
     3  import "fmt"
     4  
     5  type Foo struct {
     6  }
     7  
     8  func (Foo) Show() {
     9  	fmt.Println("Foo Showed")
    10  }
    11  
    12  func (f Foo) Call() {
    13  	fmt.Println("Foo Called")
    14  	f.Show()
    15  }
    16  
    17  type Bar struct {
    18  	Foo
    19  }
    20  
    21  type Baz struct {
    22  	Foo
    23  }
    24  
    25  func (Baz) Call() {
    26  	fmt.Println("Baz Called")
    27  }
    28  
    29  func (Baz) Show() {
    30  	fmt.Println("Baz Showed")
    31  }
    32  
    33  func main() {
    34  	Foo{}.Call()
    35  	Bar{}.Call()
    36  	Baz{}.Call()
    37  }
    38  
    39  // Output:
    40  // Foo Called
    41  // Foo Showed
    42  // Foo Called
    43  // Foo Showed
    44  // Baz Called