1
0
mirror of https://github.com/eventials/goevents.git synced 2025-04-24 13:48:53 +08:00

Remove pointer in Event Context()

This commit is contained in:
skrater 2018-10-29 14:22:17 -03:00
parent 74b5d89d4e
commit 5c35287b6f

View File

@ -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
}