Re:Down the Golang Nil Rabbit Hole
by tirrex on Tuesday March 30, 2021 @01:27AM
(#26631489)
If you add nil checks to each receiver method, potentially, you are adding thousands of unnecessary branches to your program. It would be quite inefficient. You will ruin performance & readability altogether.
Better way is what you described, accept nil state as invalid, require user to handle it (user must initialize before using your method)
Better way is what you described, accept nil state as invalid, require user to handle it (user must initialize before using your method)