github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/backup/interface41.gno (about)

     1  package main
     2  
     3  import "fmt"
     4  
     5  type foo struct {
     6  	bar string
     7  }
     8  
     9  func (f *foo) String() string {
    10  	return "Hello from " + f.bar
    11  }
    12  
    13  func Foo(s string) fmt.Stringer {
    14  	return &foo{s}
    15  }
    16  
    17  func main() {
    18  	f := Foo("bar")
    19  	fmt.Println(f)
    20  }
    21  
    22  // Output:
    23  // Hello from bar