Open
Description
Hi!
Which approach is the right one?
1.
func (o *Order) foo(e *zerolog.Event) {
...
e.Str(OrderID, o.ID)
...
}
My concern here is that func (e *Event) Str(key, val string) *Event
does not explicitly state that e
is modified in-place. It only state it adds the field key...
and it returns *Event
. So this approach based on undocumented behavior of func (e *Event) Str...
. Q: Can one day the behavior be changed, therefor this code stop working?
2.
func (o *Order) foo(e *zerolog.Event) {
...
*e = *(e.Str(OrderID, o.ID))
...
}
This approach is more robust, imo. But less readable. Should one always use this approach?
Metadata
Metadata
Assignees
Labels
No labels