|
|
|
|
|
by jrockway
4065 days ago
|
|
I think what he actually wanted was: type Shape struct {
Rectangle *Rectangle
Circle *Circle
Triangle *Triangle
}
Then you send shapes on your channel rather than interface {}. If you want to enforce having only one element populated, make the struct members private and write: func NewRectangleShape(r *Rectangle) *Shape {
return &Shape{rectangle: r}
}
|
|