func showShapeDetails(shape shapes.Shaper) { fmt.Print("fill=", shape.Fill(), " ") // All shapes have a fill color if shape, ok := shape.(shapes.Radiuser); ok { // shadow variable fmt.Print("radius=", shape.Radius(), " ") } if shape, ok := shape.(shapes.Sideser); ok { // shadow variable fmt.Print("sides=", shape.Sides(), " ") } fmt.Println() }
func sanityCheck(name string, shape shapes.Shaper) { fmt.Print("name=", name, " ") fmt.Print("fill=", shape.Fill(), " ") if shape, ok := shape.(shapes.Radiuser); ok { fmt.Print("radius=", shape.Radius(), " ") } if shape, ok := shape.(shapes.Sideser); ok { fmt.Print("sides=", shape.Sides(), " ") } fmt.Println() }