Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/gob: panic in reflect.Value.IsNil when encoding via pointer type alias #12562
Here is a program containing a type
If I'm reading the documentation correctly, this program should work as expected (printing
Note that if you change it so that the alias looks like
The program in the report seems fundamentally wrong. It makes a Alias which is *Foo, but then once gob indirects it has a Foo with an Encode method, which is going to put the recursion back. If you 'type Alias Foo', as in http://play.golang.org/p/Lby39nmUE0, then everything works today. There may be cause for a clearer error here but that's all.
The type interface documented is GobEncoder (and not GobEncode). From the problem description, you want to have the ability to use a type method accessing directly the gob encoder.
The code suggested still crashes online and loops elsewhere because the encoder is redefined. Further *Foo is not a non-interface type as per documentation and the case is not detected.
Below, is the code using GobEncoder/GobDecoder as per documentation which runs using the non-interface type.
I can recreate this with unary
The issue arises as
A sample of code that fails to this is found here. The panic occurs on line
Could this possibly be mitigated by modifying this statement to return