Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

could not import error creeps up #24

Closed
melvinodsa opened this issue Mar 19, 2016 · 16 comments
Closed

could not import error creeps up #24

melvinodsa opened this issue Mar 19, 2016 · 16 comments

Comments

@melvinodsa
Copy link

could not import fmt (can't find import: fmt) (gotype)

I am not getting any imports right. So the whole project is showing errors. But when I run my program it runs flawlessly. I tried running gometalinter independently from terminal. It has no issues but the gometalinter-linter showing error from gometalinter

@sethvargo
Copy link

I'm also experiencing this, particularly with paths in the same project. For example, given a layout like this:

$GOPATH/github.com/project/a.go
$GOPATH/github.com/project/b/c.go

where a.go imports 'github.com/project/b'. The only difference from @melvinodsa is that I am getting the error when I run gometalinter on my own, but all the application complies and runs without error.

@sethvargo
Copy link

FWIW, it actually appears to be related to golang/go#12703. After I ran go install ./..., most of the errors went away. I think this is coming from gotype.

@joefitzgerald
Copy link
Owner

So sorry you're having issues. Sounds like I should consider creating a package that provides a context menu for a directory allowing you to run go install ./.... It could optionally also show out of date packages? Not sure. What do you think?

@melvinodsa
Copy link
Author

@joefitzgerald I think the issue is with the gotype. go install didn't resolve my issues. it still fails to get the standard packages (fmt, net/http etc.) imports recognized. I had two version's of Go. first one the 1.2 it gets everything right gometalinter is like superman. But my project which 1.6 based got me in trouble. alecthomas/gometalinter#91 raises concerns over this kind of issue. It would be really cool if gometalinter-linter identifies that the Go version and try not to use gotype, instead something else (I am not sure which ones 💇 )

@sethvargo
Copy link

@melvinodsa @joefitzgerald I ended up just doing this:

  "gometalinter-linter":
    args: [
      "--vendor"
      "--disable=gotype"
      "--fast"
      "--json"
      "./..."
    ]

@melvinodsa
Copy link
Author

@sethvargo but the syntax check is ignored after gotype is disabled.

@sethvargo
Copy link

@melvinodsa many of the other linters pick up errors

@prvst
Copy link

prvst commented Mar 21, 2016

Hi, just confirming that I'm also experiencing the same problem. I have errors with files from my own projects. Having a vendor folder did not resolved.

@joefitzgerald
Copy link
Owner

For now, to make gotype work, periodically run go install ./... in your package's directory.

@dominicbarnes
Copy link

I've tried using go install ./..., and that doesn't fix any import errors for me. Are there any other workarounds or possibly some other config I can try?

@melvinodsa
Copy link
Author

I think this issue affects those who have their Go version >= 1.5. Others its fine I guess. The community has a discussion on the same and hope they will get it right in 1.7. It is referenced here :- golang/go#14727. Meanwhile we could have workaround like this:- intelligent disable gotype in gometalinter, if go version >= 1.5 and use other linters[have to look the posibility of that]. What are your thoughts about this?

@dominicbarnes
Copy link

So, is this library basically broken for go 1.5+? (I'm using 1.6) It sounds weird that I'd need to wait for 1.7 for this to (maybe) be fixed, is that the case?

@joefitzgerald
Copy link
Owner

No, it's not broken for go 1.5+. As a temporary workaround, periodically run go install . in your package directory. I am actually finishing up testing on builder-go which will completely fix this. Look for that to ship in the next hour.

@dominicbarnes
Copy link

Gotcha, I'll just wait for the fix (go install . isn't working for me)

@joefitzgerald
Copy link
Owner

This is fixed in go-plus 4.1.0 https://github.com/joefitzgerald/go-plus/releases/tag/v4.1.0.

@dominicbarnes
Copy link

Awesome! Looks like it's working for me. Thanks :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants