go: x/net/context: go vet fails because of copied Mutex
- What version of Go are you using (
go version)?
go version go1.6 linux/amd64
- What operating system and processor architecture are you using (
go env)?
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
- What did you do? If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best.
Ran go vet ./... on a project with golang.org/x/net/context/context.go in vendor/.
Also tried running go vet on a fresh clone of https://github.com/golang/net.
- What did you expect to see?
go vet to exit with status 0.
- What did you see instead?
context.go:218: newCancelCtx returns lock by value: context.cancelCtx contains sync.Mutex
exit status 1
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (6 by maintainers)
Commits related to this issue
- regexp: avoid copying mutex in (*Regexp).Copy. There's nothing guaranteeing that the *Regexp isn't in active use, and so copying the sync.Mutex value is invalid. Updates #14839. Change-Id: Iddf52bf... — committed to golang/go by dsymonds 8 years ago
- context: Uniformly pass cancelCtx by pointer. cancelCtx has an embedded sync.Mutex. This change causes an extra allocation when creating a new timerCtx via WithDeadline, but that seems minor when com... — committed to golang/net by dsymonds 8 years ago
- cmd/vet: allow lock types inside built-in new() Updates #14839 Fixes #14994 Change-Id: I9bb51bad19105a17c80d690c5486e5dd007ac84a Reviewed-on: https://go-review.googlesource.com/21222 Run-TryBot: Rob... — committed to golang/go by valyala 8 years ago
Yes