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: help prevent copying of mutexes #6729

Closed
josharian opened this issue Nov 6, 2013 · 8 comments
Closed

cmd/vet: help prevent copying of mutexes #6729

josharian opened this issue Nov 6, 2013 · 8 comments

Comments

@josharian
Copy link
Contributor

go vet feature request: If a method has a value receiver, and the receiver type contains
(directly or indirectly) an object from the sync package, warn about possible copying of
a sync primitive.

For example, in http://play.golang.org/p/5he6Ts-XgK, go vet would complain about the
method Bad.

This would have saved me several painful hours yesterday.
@josharian
Copy link
Contributor Author

Comment 1:

...and I took a quick look at implementing this. It looks non-trivial, unfortunately,
since go vet would need to know about the types involved, and that's not handy based on
just an AST walk. Might future go vet implementations share a backend with the go
oracle, to enable deeper checks like this?

@adg
Copy link
Contributor

adg commented Nov 7, 2013

Comment 2:

Go vet already knows about types, by way of the go/types package.
Check the 'types' field of the Package struct.

Status changed to Accepted.

@josharian
Copy link
Contributor Author

Comment 3:

Wow, go/types is awesome. (I wish it descended all the way into the stdlib, though.)
Started on this.

@adg
Copy link
Contributor

adg commented Nov 7, 2013

Comment 4:

Owner changed to @josharian.

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 5:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 6:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 7:

Labels changed: added repo-tools.

@josharian
Copy link
Contributor Author

Comment 8:

This issue was closed by revision golang/tools@866b24e.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants