3 ms·
https://play.golang.org/p/V3eWfbDGhXF https://play.golang.org/p/V3eWfbDGhXF In this example, by wrapping an interface in another interface, you lose the abilit
by omegabravo 7y ago
https://play.golang.org/p/V3eWfbDGhXF https://play.golang.org/p/V3eWfbDGhXF
In this example, by wrapping an interface in another interface, you lose the ability to cast back down to an interface that the original type fulfilled.
- fabianlindfors 7y agoThanks for putting that together, I see your point know. Thought you were talking about embedding when you said "wrap" before. Considering that this is not related to embedding specifically, would you say that decorators in general are bad practice in Go?
- weberc2 7y agoThis is often a reasonable thing to do (encapsulation). Callers don't have a right to private details, and I would go further and say that an interface value's concrete type is itself an implementation detail that callers shouldn't depend on unless the interface's documentation declares it stable.