Files
moxa/_test/interface46.go
Nicholas Wiersma 88569f5df7 fix: interface call regression from #787
Fix #787 changes how interfaces are set on a struct (compositeSparce). This change however makes calling the interface panic. 

This PR reverts part of the change in #787 and adds a test to ensure it does not break again.
2020-08-10 16:32:05 +02:00

36 lines
331 B
Go

package main
import "fmt"
type I interface {
Foo() string
}
type Printer struct {
i I
}
func New(i I) *Printer {
return &Printer{
i: i,
}
}
func (p *Printer) Print() {
fmt.Println(p.i.Foo())
}
type T struct{}
func (t *T) Foo() string {
return "test"
}
func main() {
g := New(&T{})
g.Print()
}
// Output:
// test