Skip to content
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

cmd/vet: doesn't warn about function literals passing Locks by value #10927

dgryski opened this issue May 21, 2015 · 2 comments


None yet
5 participants
Copy link

commented May 21, 2015

vet currently warns when a function is declared to take a Lock , but not for function types or if the function is a function literal.

<dgryski@kaepora[w] \ʕ◔ϖ◔ʔ/ > cat main.go
package main

import "sync"

var f2 func(sync.Mutex) = func(mu sync.Mutex) {}

func f(mu sync.Mutex) {}
<dgryski@kaepora[w] \ʕ◔ϖ◔ʔ/ > go vet main.go
main.go:7: f passes Lock by value: sync.Mutex
exit status 1

This comment has been minimized.

Copy link

commented May 21, 2015

Good find. This is probably relatively straightforward, if you have any interest in tackling it. It probably consists of locating and extracting the relevant types and running them through lockPath. See,, and

@ianlancetaylor ianlancetaylor added this to the Go1.5Maybe milestone Jun 3, 2015


This comment has been minimized.

Copy link

commented Jun 13, 2015

CL mentions this issue.

@josharian josharian closed this in ff8f3f0 Jun 13, 2015

@mikioh mikioh modified the milestones: Go1.5, Go1.5Maybe Jun 13, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.