-
Notifications
You must be signed in to change notification settings - Fork 798
"Can't load package" for package main
declaration
#226
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
Comments
I think you probably want to create a directory below Some additional resources are linked in our |
Thanks for the reply! My go env seems to have I'm not sure I understand the bit about having this project be under GOPATH/src - shouldn't using a module remove the need to worry about the GOPATH? I've read through the linked docs on modules, but it mostly discusses which tools don't support modules - it seems like basic building should work still? One new wrinkle: I currently have both the files for this project at |
I noticed the unusual
The go build target is determined by Can you try to run the go list command from the integrated terminal? The ImportPath will include the Is the You can also check whether the |
So yeah, it seems like it's not picking up the
It seems like maybe vscode-go isn't able to detect a go.mod that's not at the root level of the project? |
Yep, that's explained a bit more here: golang/go#36899. Does VS Code Go work when you open it from the module root (directory containing the |
Ah, thanks for that link - that's some useful context. That said, it looks like that only applies to (Yes, opening vs code from the module root seems to work) |
That's go command's limitation as well - the go command is sensitive to in which directory the go command runs. As the messages in the output channel indicated, the error occurred while building the package in the workspace, and from the workspace, the go command doesn't see the packages under the nested module directory. :-( |
Closing this in favor of the pinned issue #275. |
For vscode I have a workaround, do not know if this work for other editors. My directory structure is:
opening "Somepoject1" in vscode causes a problem.
If i start working on a project I open the respective directory in "Workspace"s in vscode. There I add al the microservice directories from the corresponding project directory in "Projects" to the workspace. it's a little bit of work to setup but it works. no errors any more |
I'm trying to set up a hello world go project using modules and vscode. I'm using the go extension without the language server. I'm getting an error on the line
package main
when it seems like it should build cleanly.My project consists of two files:
VS Code shows an error on
package main
:This seems like vscode-go ought to build this cleanly.
go build
from within the src directory builds without error, and produces a functional binary. I apologize in advance if I'm just missing a minor configuration, or if I've misunderstood something about go project organization, but any help/advice would be very much appreciated!What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gogo version go1.14.3 darwin/amd64
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders0.14.4
go env
to get the go development environment detailsShare the Go related settings you have added/edited
The text was updated successfully, but these errors were encountered: