diff --git a/messaging/event.go b/messaging/event.go index 9ebc28e..90f8f7a 100644 --- a/messaging/event.go +++ b/messaging/event.go @@ -15,21 +15,19 @@ type Event struct { // WithContext returns a shallow copy of Event with its context changed to ctx. // The provided ctx must be non-nil. -func (e *Event) WithContext(ctx context.Context) *Event { +func (e Event) WithContext(ctx context.Context) Event { if ctx == nil { panic("nil context") } - e2 := new(Event) - *e2 = *e - e2.ctx = ctx + e.ctx = ctx - return e2 + return e } -// The returned context is always non-nil; it defaults to the background context. +// Context returns the current context; if nil, it defaults to the background context. // To change the context, use WithContext. -func (e *Event) Context() context.Context { +func (e Event) Context() context.Context { if e.ctx != nil { return e.ctx }