decimal icon indicating copy to clipboard operation
decimal copied to clipboard

have string marshaling methods be value receivers rather than pointer…

Open mediocregopher opened this issue 6 years ago • 0 comments

… receivers

I frequently use Big as a value, mostly because it's convenient to do so in structs and maps, as the zero value is 0 so it makes business logic read better, rather than having to constantly do if v == nil checks everywhere. It also helps reduce allocations. The only problem I've run into is that both the formatted string outputs and JSON marshaled outputs are super wonky when I do so, because the String, Format, and MarshalText methods are on the pointer receiver. Changing those methods to be on the value receiver fixes the problem, and afaik has no adverse side-effects. So this PR does that. Let me know what you think!

mediocregopher avatar Oct 16 '19 23:10 mediocregopher