-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from x/net/context to context #1038
Conversation
|
Those are the errors uncovered by the switch to the standard package (that's a deficiency in go vet I guess). I have added commits to fix those. |
Looks like there's still some linting issues;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two nits, but no real blocker, so let me know if you want to update, otherwise we can merge as-is
LGTM
cli/command/system/version_test.go
Outdated
@@ -5,14 +5,15 @@ import ( | |||
"strings" | |||
"testing" | |||
|
|||
"context" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be grouped with the other stdlib imports
cli/command/service/list.go
Outdated
@@ -4,6 +4,8 @@ import ( | |||
"fmt" | |||
"sort" | |||
|
|||
"context" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be grouped with the above
Sure, let me update it. I was curious why my script was not working and it is because there are more than 2 groups of imports (separated by an empty line), and in case the "context" is not in the first two groups, one need to repeat the awk/goimports mantra twice. Patch updated. |
Since go 1.7, "context" is a standard package. Since go 1.9, x/net/context merely provides some types aliased to those in the standard context package. The changes were performed by the following script: for f in $(git ls-files \*.go | grep -v ^vendor/); do sed -i 's|golang.org/x/net/context|context|' $f goimports -w $f for i in 1 2; do awk '/^$/ {e=1; next;} /\t"context"$/ {e=0;} {if (e) {print ""; e=0}; print;}' < $f > $f.new && \ mv $f.new $f goimports -w $f done done [v2: do awk/goimports fixup twice] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Switch from x/net/context to context made "go vet" see the previously unseen errors: > cli/command/container/start.go:57::error: the cancelFun function is > not used on all paths (possible context leak) (vet) > cli/command/container/start.go:63::error: this return statement may be > reached without using the cancelFun var defined on line 57 (vet) > cli/command/container/run.go:159::error: the cancelFun function is not > used on all paths (possible context leak) (vet) > cli/command/container/run.go:164::error: this return statement may be > reached without using the cancelFun var defined on line 159 (vet) Do call the cancel function. Note we might end up calling it twice which is fine as long as I can see from the Go 1.10 source code. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Since go 1.7, "context" is a standard package. Since go 1.9, x/net/context merely provides some types aliased to those in the standard context package, so there is no functional change.
The changes were performed by the following script:
Similar PRs: