github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/interface13.gno (about) 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 type X struct{} 8 9 func (X) Foo() int { 10 return 1 11 } 12 13 func (X) Bar() int { 14 return 2 15 } 16 17 type Foo interface { 18 Foo() int 19 } 20 type Bar interface { 21 Bar() int 22 } 23 24 func main() { 25 var x X 26 var i Foo = x 27 j := i.(Bar) 28 29 fmt.Println(j.Bar()) 30 } 31 32 // Output: 33 // 2