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