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:
parent
74b5d89d4e
commit
5c35287b6f
@ -15,21 +15,19 @@ type Event struct {
|
|||||||
|
|
||||||
// WithContext returns a shallow copy of Event with its context changed to ctx.
|
// WithContext returns a shallow copy of Event with its context changed to ctx.
|
||||||
// The provided ctx must be non-nil.
|
// 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 {
|
if ctx == nil {
|
||||||
panic("nil context")
|
panic("nil context")
|
||||||
}
|
}
|
||||||
|
|
||||||
e2 := new(Event)
|
e.ctx = ctx
|
||||||
*e2 = *e
|
|
||||||
e2.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.
|
// To change the context, use WithContext.
|
||||||
func (e *Event) Context() context.Context {
|
func (e Event) Context() context.Context {
|
||||||
if e.ctx != nil {
|
if e.ctx != nil {
|
||||||
return e.ctx
|
return e.ctx
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user