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

Comments

Projects
None yet
4 participants
@josharian
Copy link
Contributor

commented Nov 6, 2013

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

This comment has been minimized.

Copy link
Contributor Author

commented Nov 6, 2013

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Nov 7, 2013

Comment 3:

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

This comment has been minimized.

Copy link
Contributor

commented Nov 7, 2013

Comment 4:

Owner changed to @josharian.

Status changed to Started.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Nov 27, 2013

Comment 5:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 6:

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

@rsc

This comment has been minimized.

Copy link
Contributor

commented Dec 4, 2013

Comment 7:

Labels changed: added repo-tools.

@josharian

This comment has been minimized.

Copy link
Contributor Author

commented Dec 10, 2013

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.
You can’t perform that action at this time.