Description
Please answer these questions before submitting your issue. Thanks!
- What version of Go are you using (
go version
)?
All versions of Go. - What did you do?
If possible, provide a recipe for reproducing the error.
https://play.golang.org/p/SKQxgP2jjz
Nothing is mentioned in the docs about how encoding/gob.Encode and EncodeValue handles nil pointers
While investigating issue #16204, I dug through the source code of encoding/gob/encoder.go https://github.com/golang/go/blob/master/src/encoding/gob/encoder.go#L215.
The first comment in the method internally mentions what to do with nil pointers
However the docs do not and I don't see any tests that test out this expected behavior expect for https://github.com/golang/go/blob/master/src/encoding/gob/encoder_test.go#L833 and moreover that test only ensures that a panic provides a useful message, its focus isn't on checking that nil pointers panic.
I made https://play.golang.org/p/8PB1oN2eFO and in it I pass in some nil pointers
- What did you expect to see?
The doc should be explicit about nil pointers and also we need some tests in there since panicking is the behavior in the implementation of EncodeValue which goes into Encode too.
I have a CL prepared to fix this and I'll submit it ASAP.