diff --git a/interface/interface3.go b/interface/interface3.go new file mode 100644 index 0000000..70ecea0 --- /dev/null +++ b/interface/interface3.go @@ -0,0 +1,40 @@ +package main + +import "fmt" + +type Piyo struct { + Name string +} + +type Hoge interface { + Foo() +} + +type Fuga interface { + Bar() +} + +type Parent interface { + Hoge + Fuga +} + +func (p *Piyo) Foo() { + fmt.Println("foo") + fmt.Println(p) +} + +func (p *Piyo) Bar() { + fmt.Println("bar") + fmt.Println(p) +} + +func baz(p Parent) { + p.Foo() + p.Bar() +} + +func main() { + v := Piyo{"hoge"} + baz(&v) +}