mdempsky / unconvert

Remove unnecessary type conversions from Go source
BSD 3-Clause "New" or "Revised" License
377 stars 26 forks source link

Files in /usr/local/go are processed #10

Closed Dynom closed 8 years ago

Dynom commented 8 years ago

I've reported it before here: https://github.com/alecthomas/gometalinter/issues/149, but I think that this is a better place to report it.

I'm not (yet) sure why, but some linters generate a report from /usr/local/go.

mark@Dymek:$ gometalinter -j4 --vendor --deadline=30s -t . | grep '^/'
/usr/local/go/src/os/user/lookup.go:9:9:warning: undeclared name: current (unconvert)
/usr/local/go/src/os/user/lookup.go:15:9:warning: undeclared name: lookup (unconvert)
/usr/local/go/src/os/user/lookup.go:21:9:warning: undeclared name: lookupId (unconvert)
/usr/local/go/src/net/lookup_unix.go:55:24:warning: undeclared name: cgoLookupHost (unconvert)
/usr/local/go/src/net/lookup_unix.go:67:24:warning: undeclared name: cgoLookupIP (unconvert)
/usr/local/go/src/net/lookup_unix.go:78:23:warning: undeclared name: cgoLookupPort (unconvert)
/usr/local/go/src/net/lookup_unix.go:87:24:warning: undeclared name: cgoLookupCNAME (unconvert)
/usr/local/go/src/net/lookup_unix.go:154:23:warning: undeclared name: cgoLookupPTR (unconvert)
/usr/local/go/src/crypto/x509/root.go:15:10:warning: undeclared name: initSystemRoots (unconvert)
/usr/local/go/src/os/user/lookup.go:9:9:warning: unused global variable undeclared name: current (varcheck)
/usr/local/go/src/os/user/lookup.go:15:9:warning: unused global variable undeclared name: lookup (varcheck)
/usr/local/go/src/os/user/lookup.go:21:9:warning: unused global variable undeclared name: lookupId (varcheck)
/usr/local/go/src/net/lookup_unix.go:55:24:warning: unused global variable undeclared name: cgoLookupHost (varcheck)
/usr/local/go/src/net/lookup_unix.go:67:24:warning: unused global variable undeclared name: cgoLookupIP (varcheck)
/usr/local/go/src/net/lookup_unix.go:78:23:warning: unused global variable undeclared name: cgoLookupPort (varcheck)
/usr/local/go/src/net/lookup_unix.go:87:24:warning: unused global variable undeclared name: cgoLookupCNAME (varcheck)
/usr/local/go/src/net/lookup_unix.go:154:23:warning: unused global variable undeclared name: cgoLookupPTR (varcheck)
/usr/local/go/src/crypto/x509/root.go:15:10:warning: unused global variable undeclared name: initSystemRoots (varcheck)
/usr/local/go/src/os/user/lookup.go:9:9:warning: unused struct field undeclared name: current (structcheck)
/usr/local/go/src/os/user/lookup.go:15:9:warning: unused struct field undeclared name: lookup (structcheck)
/usr/local/go/src/os/user/lookup.go:21:9:warning: unused struct field undeclared name: lookupId (structcheck)
/usr/local/go/src/net/lookup_unix.go:55:24:warning: unused struct field undeclared name: cgoLookupHost (structcheck)
/usr/local/go/src/net/lookup_unix.go:67:24:warning: unused struct field undeclared name: cgoLookupIP (structcheck)
/usr/local/go/src/net/lookup_unix.go:78:23:warning: unused struct field undeclared name: cgoLookupPort (structcheck)
/usr/local/go/src/net/lookup_unix.go:87:24:warning: unused struct field undeclared name: cgoLookupCNAME (structcheck)
/usr/local/go/src/net/lookup_unix.go:154:23:warning: unused struct field undeclared name: cgoLookupPTR (structcheck)
/usr/local/go/src/crypto/x509/root.go:15:10:warning: unused struct field undeclared name: initSystemRoots (structcheck)
/usr/local/go/src/os/user/lookup.go:9:9:warning: undeclared name: current (aligncheck)
/usr/local/go/src/os/user/lookup.go:15:9:warning: undeclared name: lookup (aligncheck)
/usr/local/go/src/os/user/lookup.go:21:9:warning: undeclared name: lookupId (aligncheck)
/usr/local/go/src/net/lookup_unix.go:55:24:warning: undeclared name: cgoLookupHost (aligncheck)
/usr/local/go/src/net/lookup_unix.go:67:24:warning: undeclared name: cgoLookupIP (aligncheck)
/usr/local/go/src/net/lookup_unix.go:78:23:warning: undeclared name: cgoLookupPort (aligncheck)
/usr/local/go/src/net/lookup_unix.go:87:24:warning: undeclared name: cgoLookupCNAME (aligncheck)
/usr/local/go/src/net/lookup_unix.go:154:23:warning: undeclared name: cgoLookupPTR (aligncheck)
/usr/local/go/src/crypto/x509/root.go:15:10:warning: undeclared name: initSystemRoots (aligncheck)

I'm on go version go1.6.2 darwin/amd64

mark@Dymek:$ set | grep ^GO
GOBIN=/Users/mark/Development/GO/bin
GOPATH=/Users/mark/Development/GO
GOROOT=/usr/local/go

/usr/local/go is a symlink, not sure if that's significant.

When I try to run unconvert directly, I get similar behaviour.

mdempsky commented 8 years ago

Sorry, I don't understand your issue. None of those warnings are produced by unconvert.

Can you please provide: 1) the unconvert command you ran, 2) the actual output produced, and 3) the output you expected to be produced?

Thanks!

mdempsky commented 8 years ago

Oh, sorry, I see "(unconvert)" now. Odd.

mdempsky commented 8 years ago

I suspect there's something wrong with your /usr/local/go directory that's causing go/types to fail to type check the packages. Can you provide the output from ls /usr/local/go/src/os/user?

dmitshur commented 8 years ago

/usr/local/go is a symlink, not sure if that's significant.

It's quite likely this is significant. It might be that the check if a package is inside GOROOT is failing when your /usr/local/go is a symlink, causing it to think os/user is a 3rd party package.

This is just a guess based on that others (without symlinks) don't seem to run into this issue.

mdempsky commented 8 years ago

I'm actually now suspecting it's a problem related to cgo and/or build tags. Not sure how to diagnose that though.

Dynom commented 8 years ago

@shurcooL I think the symlink approach is common. I don't recall doing anything specific with it and so it's probably setup by Homebrew. Again I'm not entirely sure.

@mdempsky

$ l /usr/local/go/src/os/user
total 56
drwxr-xr-x   9 mark  admin   306B Apr 20 01:50 ./
drwxr-xr-x  68 mark  admin   2.3K Apr 20 01:50 ../
-rw-r--r--   1 mark  admin   645B Apr 20 01:50 lookup.go
-rw-r--r--   1 mark  admin   855B Apr 20 01:50 lookup_plan9.go
-rw-r--r--   1 mark  admin   699B Apr 20 01:50 lookup_stubs.go
-rw-r--r--   1 mark  admin   3.1K Apr 20 01:50 lookup_unix.go
-rw-r--r--   1 mark  admin   3.4K Apr 20 01:50 lookup_windows.go
-rw-r--r--   1 mark  admin   1.1K Apr 20 01:50 user.go
-rw-r--r--   1 mark  admin   1.8K Apr 20 01:50 user_test.go

Also:

I suspect there's something wrong with your /usr/local/go directory that's causing go/types to fail to type check the packages. Can you provide the output from ls /usr/local/go/src/os/user?

That might be the case, but why does it check those paths in the first place..?

Dynom commented 8 years ago

I solved it.. I updated Xcode to a more recent version and now I have no errors.

wtf

mdempsky commented 8 years ago

Xcode includes clang, right? Perhaps it fixed something related to cgo. No idea how though, since go/types doesn't actually invoke cgo. :-/

Glad to hear it's fixed at least.