Re:Down the Golang Nil Rabbit Hole
by gher-shyu3i on Tuesday March 30, 2021 @07:18AM
(#26633262)
And implement that check in each and every function that has a receiver? That sounds like a recipe for bad performance (unnecessary branching), as well as unnecessary readability affects.
[ Parent
| on HN ]
Not necessarily. It's suggested as a way to maintain the typing decision the original parent made, but which itself is undesirable. The pattern can be changed to,
func main() {
var c Compressor // signal do nothing
DoCompress(c)
c = &GZipComprosser{} // normal call
DoCompress(c)
}