Switch from x/net/context to context#1038
Merged
cpuguy83 merged 2 commits intodocker:masterfrom May 12, 2018
Merged
Conversation
Collaborator
|
Contributor
Author
|
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. |
Member
|
Looks like there's still some linting issues; |
thaJeztah
approved these changes
May 11, 2018
cli/command/system/version_test.go
Outdated
| "strings" | ||
| "testing" | ||
|
|
||
| "context" |
Member
There was a problem hiding this comment.
nit: should be grouped with the other stdlib imports
cli/command/service/list.go
Outdated
| "fmt" | ||
| "sort" | ||
|
|
||
| "context" |
Member
There was a problem hiding this comment.
nit: should be grouped with the above
Contributor
Author
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: