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
Hi, currently Logger uses a mix of value and pointer semantics, e.g., WithContext has a value receiver, Fatal, Err etc have pointer receivers, why is this? sorry if this has been brought up before
The text was updated successfully, but these errors were encountered:
In general in Go, pointer receivers are used when you want to modify the struct inside the method, and value receiver when you do not do so (or, you return a copy). I think zerolog is pretty consistent in using one or the other so that it does not needlessly use pointer receivers when they are not really needed.
I am not sure how is this preventing anyone from returning objects from function calls? With zerolog you do have to be mindful when you are making a copy of the struct and when you are modifying struct in-place. Are you talking about that?
Also FAQ on this topic. It does recommend having consistency here in having all methods use pointer receivers. I think this is a bit of historical thing with zerolog while its API developed.
Hi, currently
Logger
uses a mix of value and pointer semantics, e.g.,WithContext
has a value receiver,Fatal
,Err
etc have pointer receivers, why is this? sorry if this has been brought up beforeThe text was updated successfully, but these errors were encountered: