Great! Nothing to add, you pretty much nailed it. Your example is clear and concise. Thumbs upped the issue.
My example is more of a "working case" where the lack of compiler checks or better panic messages can lead to long debugging before you get that forehead-slapping revelation.
@aclements asked:
Would it be an improvement simply for the message to say "nil value" instead of "nil pointer"? Did "nil pointer" lead you in the wrong direction?
I think the real issue is that the error message doesn't make it clear that it's the embedded interface that is nil. I looked for a nil member, or the instance being nil itself, but I didn't think of checking the embedded interfaces.
I guess it's also part of being used to inheritance from C++ and Java (and generally learning to code in the 90s-00s), and I'll get used to double-checking embedded types. But it wouldn't hurt to have a more explicit error message, that would shave a few minutes off debugging the panic, even for experienced Go practitioners. And it would also ease the path for newcomers.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great! Nothing to add, you pretty much nailed it. Your example is clear and concise. Thumbs upped the issue.
My example is more of a "working case" where the lack of compiler checks or better panic messages can lead to long debugging before you get that forehead-slapping revelation.
@aclements asked:
Would it be an improvement simply for the message to say "nil value" instead of "nil pointer"? Did "nil pointer" lead you in the wrong direction?
I think the real issue is that the error message doesn't make it clear that it's the embedded interface that is
nil
. I looked for anil
member, or the instance beingnil
itself, but I didn't think of checking the embedded interfaces.I guess it's also part of being used to inheritance from C++ and Java (and generally learning to code in the 90s-00s), and I'll get used to double-checking embedded types. But it wouldn't hurt to have a more explicit error message, that would shave a few minutes off debugging the panic, even for experienced Go practitioners. And it would also ease the path for newcomers.