Skip to content

Commit 9d0d4b8

Browse files
committed
context pkg: untangle
Since Go 1.7, "context" is a standard package, superceding the "x/net/context". Since Go 1.9, the latter only provides type aliases from the former. Therefore, it makes sense to switch to the standard package, and the change is not disruptive in any sense. This commit deals with a few cases where both packages happened to be imported by the same source file. A choice between "context" and "gocontext" was made for each file in order to minimize the patch. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent f337075 commit 9d0d4b8

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

cmd/containerd/command/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package command
1818

1919
import (
20-
"context"
20+
gocontext "context"
2121
"fmt"
2222
"io/ioutil"
2323
golog "log"
@@ -35,7 +35,6 @@ import (
3535
"github.com/pkg/errors"
3636
"github.com/sirupsen/logrus"
3737
"github.com/urfave/cli"
38-
gocontext "golang.org/x/net/context"
3938
"google.golang.org/grpc/grpclog"
4039
)
4140

@@ -168,7 +167,7 @@ func App() *cli.App {
168167
return app
169168
}
170169

171-
func serve(ctx context.Context, l net.Listener, serveFunc func(net.Listener) error) {
170+
func serve(ctx gocontext.Context, l net.Listener, serveFunc func(net.Listener) error) {
172171
path := l.Addr().String()
173172
log.G(ctx).WithField("address", path).Info("serving...")
174173
go func() {

services/images/local.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package images
1818

1919
import (
20-
gocontext "context"
20+
"context"
2121

2222
eventstypes "github.com/containerd/containerd/api/events"
2323
imagesapi "github.com/containerd/containerd/api/services/images/v1"
@@ -30,7 +30,6 @@ import (
3030
"github.com/containerd/containerd/plugin"
3131
"github.com/containerd/containerd/services"
3232
ptypes "github.com/gogo/protobuf/types"
33-
"golang.org/x/net/context"
3433
"google.golang.org/grpc"
3534
"google.golang.org/grpc/codes"
3635
"google.golang.org/grpc/status"
@@ -64,7 +63,7 @@ func init() {
6463
}
6564

6665
type gcScheduler interface {
67-
ScheduleAndWait(gocontext.Context) (gc.Stats, error)
66+
ScheduleAndWait(context.Context) (gc.Stats, error)
6867
}
6968

7069
type local struct {

services/snapshots/service.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package snapshots
1818

1919
import (
20-
gocontext "context"
20+
"context"
2121

2222
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
2323
"github.com/containerd/containerd/api/types"
@@ -29,7 +29,6 @@ import (
2929
"github.com/containerd/containerd/snapshots"
3030
ptypes "github.com/gogo/protobuf/types"
3131
"github.com/pkg/errors"
32-
"golang.org/x/net/context"
3332
"google.golang.org/grpc"
3433
)
3534

@@ -216,7 +215,7 @@ func (s *service) List(sr *snapshotsapi.ListSnapshotsRequest, ss snapshotsapi.Sn
216215
})
217216
}
218217
)
219-
err = sn.Walk(ss.Context(), func(ctx gocontext.Context, info snapshots.Info) error {
218+
err = sn.Walk(ss.Context(), func(ctx context.Context, info snapshots.Info) error {
220219
buffer = append(buffer, fromInfo(info))
221220

222221
if len(buffer) >= 100 {

0 commit comments

Comments
 (0)