We recently had a crash in our code because of an interface != nil
issue (covered in FAQ as https://golang.org/doc/faq#nil_error).

The thing that made it more subtle than the typical error interface
case is that the assignment from a function returning a concrete type
was made to an interface field within a struct.  If the function had
returned the same type as the field (either as an interface or
concrete type) then the crash would not have happened.  A simplified
example is here: https://play.golang.org/p/8Xmj_LJY3yT

The fix is easy enough, but now we need to go through our code and
audit all field assignments from functions to see if there is an
interface conversion.  This could happen if refactoring from a
concrete type to an interface and would not be caught at compile time.

Are there any vet or lint checks that would have caught that?  If not,
my request is that a check for this be added to vet or lint because
this issue can be otherwise hard to find.

Thanks,
Tarmigan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to