Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/gob: panics encoding nil pointer - reopen #31664
This isssue is related to #3704 (cannot be reopened)
Currently encoding/gob panics if it is not able to do something. It's incorrect as this cannot be caught and supported on code level to provide "workaround" or failsafe activity to recover.
I'm not convinced by "that's the way it should react" in response of related message.
As you see I don't care about panic here. It can be empty in my case.
This error could be supported on code level if it's catchable - in my context for example I can skip object that has nil pointer because it will not be deserialized back.
I would expect to have error returned so it will be caught and workaround could be done.
Solved by additional implementaiton of check. Still enc.Encode() should return error and not panic.
And the diff: