* fix: use interface wrappers to expose interface values to runtime If a value is assigned to, or returned as, a binary interface, then use the interface wrapper generator to convert the value accordingly. Fixes #630. * test: rename NewFoo in Foo * test: rename NewFoo in Foo * fix: improve branch flow to reduce indentation
24 lines
258 B
Go
24 lines
258 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type foo struct {
|
|
bar string
|
|
}
|
|
|
|
func (f *foo) String() string {
|
|
return "Hello from " + f.bar
|
|
}
|
|
|
|
func Foo(s string) fmt.Stringer {
|
|
return &foo{s}
|
|
}
|
|
|
|
func main() {
|
|
f := Foo("bar")
|
|
fmt.Println(f)
|
|
}
|
|
|
|
// Output:
|
|
// Hello from bar
|