vladimirvivien / learning-go

Source code repository for my book "Learning Go Programming"
https://www.packtpub.com/application-development/learning-go-programming
BSD 2-Clause "Simplified" License
232 stars 84 forks source link

learning-go/ch08/interface_impl3.go #2

Open modernix opened 6 years ago

modernix commented 6 years ago

Hi Vladimir,

I ran into this issue while testing out the interface examples. ./interface_impl3.go:83:37: s.area undefined (type interface {} is interface with no methods)

To workaround the issue, I modified the shapeInfo func.

func shapeInfo(s interface{}) string { if str, ok := s.(shape); ok { return fmt.Sprintf("Area = %.2f", str.(shape).area()) } return "" }

vladimirvivien commented 6 years ago

Thanks for pointing this out @modernix