Personally, I'd argue that you are misattributing the root cause. The code
you posted at least, does not check the error of ensureOpen. If it would
have, then it wouldn't have crashed. It is pretty common in Go, to return a
valid value if and only if no error is returned alongside it. It is also
no
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 fiel