...
1
2 package xcontext
3
4 import (
5 "context"
6 "time"
7 )
8
9
10
11 func WithoutCancel(ctx context.Context) context.Context {
12 return withoutCancel{ctx: ctx}
13 }
14
15 type withoutCancel struct {
16 ctx context.Context
17 }
18
19 func (c withoutCancel) Deadline() (time.Time, bool) {
20 return time.Time{}, false
21 }
22
23 func (c withoutCancel) Done() <-chan struct{} {
24 return nil
25 }
26
27 func (c withoutCancel) Err() error {
28 return nil
29 }
30
31 func (c withoutCancel) Value(key interface{}) interface{} {
32 return c.ctx.Value(key)
33 }
34
35
36
37 func WithoutValues(ctx context.Context) context.Context {
38 return withoutValues{ctx: ctx}
39 }
40
41 type withoutValues struct {
42 ctx context.Context
43 }
44
45 func (c withoutValues) Deadline() (time.Time, bool) {
46 return c.ctx.Deadline()
47 }
48
49 func (c withoutValues) Done() <-chan struct{} {
50 return c.ctx.Done()
51 }
52
53 func (c withoutValues) Err() error {
54 return c.ctx.Err()
55 }
56
57 func (c withoutValues) Value(key interface{}) interface{} {
58 return nil
59 }
60
View as plain text