| 1 | Retrieved from
|
| 2 | <https://patch-diff.githubusercontent.com/raw/jbenet/go-context/pull/3.patch>.
|
| 3 |
|
| 4 | From a55d3832cfe7bb061123c7e90ed3c6195d8ce890 Mon Sep 17 00:00:00 2001
|
| 5 | From: Prudhvi Surapaneni <[email protected]>
|
| 6 | Date: Wed, 13 Mar 2019 16:29:55 -0500
|
| 7 | Subject: [PATCH] No-longer necessary to import context package
|
| 8 |
|
| 9 | ---
|
| 10 | dag/dagctx.go | 3 +--
|
| 11 | dag/dagctx_test.go | 3 +--
|
| 12 | frac/fracctx.go | 3 +--
|
| 13 | frac/fracctx_test.go | 12 +++++++-----
|
| 14 | io/ctxio.go | 3 +--
|
| 15 | io/ctxio_test.go | 3 +--
|
| 16 | 6 files changed, 12 insertions(+), 15 deletions(-)
|
| 17 |
|
| 18 | diff --git a/dag/dagctx.go b/dag/dagctx.go
|
| 19 | index 521390b..17a9090 100644
|
| 20 | |
| 21 | |
| 22 | @@ -1,10 +1,9 @@
|
| 23 | package ctxext
|
| 24 |
|
| 25 | import (
|
| 26 | + "context"
|
| 27 | "sync"
|
| 28 | "time"
|
| 29 | -
|
| 30 | - context "golang.org/x/net/context"
|
| 31 | )
|
| 32 |
|
| 33 | // WithParents returns a Context that listens to all given
|
| 34 | diff --git a/dag/dagctx_test.go b/dag/dagctx_test.go
|
| 35 | index 30a27e2..8692f54 100644
|
| 36 | |
| 37 | |
| 38 | @@ -1,11 +1,10 @@
|
| 39 | package ctxext
|
| 40 |
|
| 41 | import (
|
| 42 | + "context"
|
| 43 | "math/rand"
|
| 44 | "testing"
|
| 45 | "time"
|
| 46 | -
|
| 47 | - context "golang.org/x/net/context"
|
| 48 | )
|
| 49 |
|
| 50 | func TestWithParentsSingle(t *testing.T) {
|
| 51 | diff --git a/frac/fracctx.go b/frac/fracctx.go
|
| 52 | index 60938c0..d1ee94a 100644
|
| 53 | |
| 54 | |
| 55 | @@ -2,9 +2,8 @@
|
| 56 | package ctxext
|
| 57 |
|
| 58 | import (
|
| 59 | + "context"
|
| 60 | "time"
|
| 61 | -
|
| 62 | - context "golang.org/x/net/context"
|
| 63 | )
|
| 64 |
|
| 65 | // WithDeadlineFraction returns a Context with a fraction of the
|
| 66 | diff --git a/frac/fracctx_test.go b/frac/fracctx_test.go
|
| 67 | index c6dd10d..8de81be 100644
|
| 68 | |
| 69 | |
| 70 | @@ -1,11 +1,10 @@
|
| 71 | package ctxext
|
| 72 |
|
| 73 | import (
|
| 74 | + "context"
|
| 75 | "os"
|
| 76 | "testing"
|
| 77 | "time"
|
| 78 | -
|
| 79 | - context "golang.org/x/net/context"
|
| 80 | )
|
| 81 |
|
| 82 | // this test is on the context tool itself, not our stuff. it's for sanity on ours.
|
| 83 | @@ -14,7 +13,8 @@ func TestDeadline(t *testing.T) {
|
| 84 | t.Skip("timeouts don't work reliably on travis")
|
| 85 | }
|
| 86 |
|
| 87 | - ctx, _ := context.WithTimeout(context.Background(), 5*time.Millisecond)
|
| 88 | + ctx, cncl := context.WithTimeout(context.Background(), 5*time.Millisecond)
|
| 89 | + defer cncl()
|
| 90 |
|
| 91 | select {
|
| 92 | case <-ctx.Done():
|
| 93 | @@ -46,8 +46,10 @@ func TestDeadlineFractionHalf(t *testing.T) {
|
| 94 | t.Skip("timeouts don't work reliably on travis")
|
| 95 | }
|
| 96 |
|
| 97 | - ctx1, _ := context.WithTimeout(context.Background(), 10*time.Millisecond)
|
| 98 | - ctx2, _ := WithDeadlineFraction(ctx1, 0.5)
|
| 99 | + ctx1, cncl1 := context.WithTimeout(context.Background(), 10*time.Millisecond)
|
| 100 | + defer cncl1()
|
| 101 | + ctx2, cncl2 := WithDeadlineFraction(ctx1, 0.5)
|
| 102 | + defer cncl2()
|
| 103 |
|
| 104 | select {
|
| 105 | case <-ctx1.Done():
|
| 106 | diff --git a/io/ctxio.go b/io/ctxio.go
|
| 107 | index b4f2454..b27689b 100644
|
| 108 | |
| 109 | |
| 110 | @@ -11,9 +11,8 @@
|
| 111 | package ctxio
|
| 112 |
|
| 113 | import (
|
| 114 | + "context"
|
| 115 | "io"
|
| 116 | -
|
| 117 | - context "golang.org/x/net/context"
|
| 118 | )
|
| 119 |
|
| 120 | type ioret struct {
|
| 121 | diff --git a/io/ctxio_test.go b/io/ctxio_test.go
|
| 122 | index 884e090..bc4a0e9 100644
|
| 123 | |
| 124 | |
| 125 | @@ -2,11 +2,10 @@ package ctxio
|
| 126 |
|
| 127 | import (
|
| 128 | "bytes"
|
| 129 | + "context"
|
| 130 | "io"
|
| 131 | "testing"
|
| 132 | "time"
|
| 133 | -
|
| 134 | - context "golang.org/x/net/context"
|
| 135 | )
|
| 136 |
|
| 137 | func TestReader(t *testing.T) {
|