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: the code in the workspace failed to compile #40790
Comments
Are you using the vscode-go extension? If so, what version is it? Have you tried the troubleshooting steps described in https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md? /cc @stamblerre |
Looks like |
i have met the same problems, version 0.16.1. i have set go.mod file correctly(GOMOD is ok). But the promotion is always occured when i open modify etc... |
I have solved this question
I have solved this problem in vscode.In setting json,I add "go.buildOnSave": "workspace", |
Glad you were able to solve it. I'm going to close this issue. @mrlay, please file a new issue to continue this discussion. |
I also encountered the same type of error in the vscode and go plugins
|
@PICKQUE: Please make sure to open your workspace to your module root (the directory containing the |
@kittyhappy thanks your advice, which help solve it. @PICKQUE you can try create a *.code-workspace project files, and add the configurations which @kittyhappy adviced, may be the case would be solved. |
i'm sure the root directory exist the go.mod and the go version is 1.15(i'm upgrade yesterday,but it's not work |
Wonderful! Solved my problem! |
I have sloved this problem by using |
When I was developing Golang with Vscode on MacOS, vscode prompt "The code in the workspace failed to compile (see the error message below). If you believe this is a mistake, please file an issue: https://github.com/golang/go/issues/new. go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./]: exit status 1: go: cannot find main module; see 'go help modules' : packages.Load error" |
@wenchao5211: Please follow the steps in the troubleshooting guide and file a new issue so we can help you understand the problem. |
I also have this problem. How can I solve it? |
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 for the first time I open the respective directory in "Workspace"s in vscode. Then I save the workplace in the same place. Then I add al the microservice directories from the corresponding project directory in "Projects" to the workspace. When closing the workspace I save it. it's a little bit of work to setup but it works. no errors any more |
Sorry, I got it resolved, but thank you very much!
…---Original---
From: "D4v1dW3bb"<notifications@github.com>
Date: Tue, Nov 17, 2020 17:35 PM
To: "golang/go"<go@noreply.github.com>;
Cc: "Comment"<comment@noreply.github.com>;"A7"<1123511349@QQ.com>;
Subject: Re: [golang/go] x/tools/gopls: the code in the workspace failed to compile (#40790)
Unsupported
Open a directory that contains a module in a subdirectory. gopls will not work in this case.
For vscode I have a workaround, do not know if this work for other editors.
My directory structure is:
Projects Someproject1 microservice1 go.mod go.sum main.go microservice2 go.mod go.sum main.go Someproject2 ...
opening "Somepoject1" in vscode causes a problem.
To solve this I have made a second directory structure:
Workspaces
If i start working on a project for the first time I open the respective directory in "Workspace"s in vscode. Then I save the workplace in the same place. Then I add al the microservice directories from the corresponding project directory in "Projects" to the workspace. When closing the workspace I save it.
If I want to start working on an existing workspace I choose open workspace and choose the right workspace file.
it's a little bit of work to setup but it works.
no errors any more
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
when I use vscode open my gopath folder, it shows that The code in the workspace failed to compile (see the error message below) and go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./]: exit status 1: go: cannot find main module; see 'go help modules': packages.Load error.
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: