diff --git a/interface/interface2.go b/interface/interface2.go new file mode 100644 index 0000000..401f409 --- /dev/null +++ b/interface/interface2.go @@ -0,0 +1,27 @@ +package main + +import "fmt" + +type Hoge struct { + Name string +} + +type Parent interface { + hoge(b bool) + fuga() +} + +func (p *Hoge) hoge(b bool) { + fmt.Println(p.Name) +} + +func fuga(v Parent) { + v.hoge(true) +} + + +func main() { + v := Hoge{"taro"} + //fuga(&v) // build error + fmt.Println(v) +}