From 5c35287b6f8b26472249752461ab749cc6425231 Mon Sep 17 00:00:00 2001 From: skrater Date: Mon, 29 Oct 2018 14:22:17 -0300 Subject: [PATCH] Remove pointer in Event Context() --- messaging/event.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 }