Open mrkagelui opened 1 year ago
I'm very curious too. Pointer receivers prevent me from using zerolog.Logger
objects returned from a function call.
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?
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