...
1
2
3
4
5
6
7
8
9
10
11
12
13 package mockdb
14
15 import (
16 "context"
17 "time"
18 )
19
20 var startime = time.Now()
21
22
23 type canceledContext struct {
24 ch <-chan struct{}
25 }
26
27 var _ context.Context = &canceledContext{}
28
29 func newCanceledContext() context.Context {
30 ch := make(chan struct{})
31 close(ch)
32 return &canceledContext{ch}
33 }
34
35 func (c *canceledContext) Deadline() (time.Time, bool) {
36 return startime, true
37 }
38
39 func (c *canceledContext) Done() <-chan struct{} {
40 return c.ch
41 }
42
43 func (c *canceledContext) Err() error { return context.Canceled }
44
45 func (c *canceledContext) Value(_ interface{}) interface{} { return nil }
46
View as plain text