You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of now the method can be called only on a not nil Error.
I stumbled upon the situation where I wanted handle how many errors a multierror variable contained, however Len can't be called on a nil multierror (which would cause a runtime panic).
This implies that a nil multierror and zero length multierror are treated differently. I would expect the example in the playground to return 0 instead of throwing a panic. Is this an intentional design choice or maybe there is room for improvement?
I should also add that his condition happens when a multierror is initialized but nothing has been appended to it, in fact appending nil errors correctly fills it with zeroes. https://play.golang.org/p/B3P_aNnms2W
The text was updated successfully, but these errors were encountered:
As of now the method can be called only on a not nil Error.
I stumbled upon the situation where I wanted handle how many errors a multierror variable contained, however Len can't be called on a nil multierror (which would cause a runtime panic).
This implies that a nil multierror and zero length multierror are treated differently. I would expect the example in the playground to return 0 instead of throwing a panic. Is this an intentional design choice or maybe there is room for improvement?
https://play.golang.org/p/n7fwsjBybhs
The Len() method could be changed as the following without breaking changes (I think):
Otherwise one would need to go through the ErrOrNil method with little, although not needed, overhead.
I should also add that his condition happens when a multierror is initialized but nothing has been appended to it, in fact appending nil errors correctly fills it with zeroes.
https://play.golang.org/p/B3P_aNnms2W
The text was updated successfully, but these errors were encountered: