| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package xcontext |
| 8 |
|
| 9 |
import ( |
| 10 |
"context" |
| 11 |
"time" |
| 12 |
) |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
func Detach(ctx context.Context) context.Context { return detachedContext{ctx} } |
| 17 |
|
| 18 |
type detachedContext struct{ parent context.Context } |
| 19 |
|
| 20 |
func (v detachedContext) Deadline() (time.Time, bool) { return time.Time{}, false } |
| 21 |
func (v detachedContext) Done() <-chan struct{} { return nil } |
| 22 |
func (v detachedContext) Err() error { return nil } |
| 23 |
func (v detachedContext) Value(key any) any { return v.parent.Value(key) } |