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
x/tools/gopls: unable to import packages (GOPATH) #39560
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
.spacemacs:
|
Please follow the troubleshooting guide linked above. In particular, make sure your program compiles with "go build" and attach logs. |
Well, I dosen't compile now specifically, because I'm in the middle of overhauling it, but it did when I was having the issue. As for logs, I don't know how I would do that, and it sounds like it would be kind of a pain. There's about 3 layers between me and gopls, so It seems quite hard. As for the troubleshooting guide, yes, I tried both of the 2 suggestions, and they didn't work. |
Based on the |
@stamblerre |
A common issue is that you must open your workspace root to a directory that is at the root or a subdirectory of your module (the directory containing the You can also run |
the module problem sounds like a likely cause, unfortunately I don't understand much about it. the only I ran the suggested command, and I got
|
Thanks for the clarification and the logs. It sounds like your intention is to use However, it looks like your project is not in your |
@stamblerre huh, so apparently I've been programming go wrong the whole time. surprised the compiler didn't complain about it, with how picky it is. Guess that's what I get for skimming tutorials. |
You can avoid putting your code in Since it seems that we've uncovered the problem, can this issue be closed? |
Sadly, even after moving my project into |
Please provide the updated output of |
(many of these errors are cascading errors due to the library that a function is in not being imported). |
@lolbinarycat: It looks like |
Tried that, still getting errors. Is there a timeout option or something somewhere? It's very strange that the errors are different every time, even with the same file. |
Is it possible that the errors are ordered differently but are still the same? |
For
No, the errors are not the same. The reason I stopped sharing the output is that due to several unrelated issues, they are quite cumbersome to copy paste, and running the command twice while changing nothing generates two different outputs. This means that for any given thing I try, there is a practically unlimited number of outputs I could get. And the command does not run quickly on my computer. |
I really cannot help you resolve this issue without the output of those commands. My best guess is that your GOPATH remains somewhat misconfigured, and |
If it was just GOPATH being misconfigured, I would expect the errors to be the same every time.
|
Well that is certainly an improvement. It also looks like there may be an issue in your code:
seems like a legitimate error, indicating you have multiple |
@stamblerre Yes, all the packages are in GOPATH. The code is avalible here. While there is only one main function in main.go, editor.go (a file that I was going to do something with but never got around to it), also starts with |
Thank you for sharing the link to the source code - I'm able to reproduce this issue. I'll spend some time debugging to understand what's going on. |
I haven't fully investigated this, but the issue is almost certainly related to minimal module compatibility, as documented on the modules wiki. The true import path of I'll see if there's a quick fix, but I'd suggest switching to module mode by running |
Change https://golang.org/cl/238260 mentions this issue: |
switching to module mode seems to have fixed the issue. |
Perfect. |
What did you do?
I was working on this program in spacemacs using lsp-mode with gopls
What did you expect to see?
there should be no errors with package imports, as the program compiles and runs
What did you see instead?
3 package errors for the lines with:
"github.com/oakmound/oak/collision"
"github.com/oakmound/oak/key"
"github.com/oakmound/oak/render"
each error in the form of "could not import PACKAGENAME (no package for import PACKAGENAME)
Build info
Go info
The text was updated successfully, but these errors were encountered: