While I agree nils are a problem with this: as long as they have access to the type at all, they can create zero values. E.g.
var c color.Color
That's a valid color whether it's a nil interface value or an empty typed string.
You can return a private type to prevent this, but that also means they can't refer to it as an argument or return value anywhere outside the implementing package, which is a rather severe limit in many cases.
You can return a private type to prevent this, but that also means they can't refer to it as an argument or return value anywhere outside the implementing package, which is a rather severe limit in many cases.
Sometimes* I really miss constructors.
*: all the time