typed nil interface is not nil, bit me again
Classic Go gotcha but I got bitten anyway. I have a function returning error where I do var e *MyError and return e when nothing went wrong, expecting err == nil to be true. It isn't. The interface holds a nil pointer, so it's non-nil. Why does Go do this and what's the clean way to avoid it? I will keep digging in the meantime.
4 replies