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
proposal: spec: use zero receiver for value method invoked via nil pointer #18775
Currently, if a method is defined on a value type, that method is also
This means there's no way to define a method that works on all possible
I propose that when a value method is called on a nil pointer, instead of panicking,
As this breaks code that currently relies on catching this panic (notably the
If we adopt this it would change the behavior of existing code. That is, the exact same code would compile and run before and after making this change to the language, but it would behave differently. That makes it difficult to implement according to the guidelines at https://github.com/golang/proposal/blob/master/design/28221-go2-transitions.md . I'm not sure the benefit of making this change is worth the cost of having the same code behave differently in different versions of Go.