-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
question: "go: cannot find main module; see 'go help modules'" #31997
Comments
You probably still have |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
I am having the exact same problem. Have unset the environment variable. Also tried with auto, nothing changes. We have monorepo here, so it's only one go.mod in the root for the entire project. I imagine this is causing the confusion? Any ideas on how to debug this? |
Hello @marcelotoledo, unlike other projects, we do not use the issue tracker for questions such as these. It is only used for bugs and feature proposals. Please feel free to ask it in any of these forums below:
Thanks |
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 |
After upgrade to go1.16, try to set :
https://blog.golang.org/go116-module-changes Thx |
@dwbuiten It worked on my machine, thank you. |
You're the GOAT |
Works for me, was missing this & getting the same error with go koans. |
This issue is closed, but it looks like a lot of people are seeing similar error messages since module-aware mode is now enabled by default in Go 1.16 (#41330). I've opened #44745 to clarify the error messages. That should explain the problem and suggest a solution when possible. I'd like to backport that to the next 1.16 patch release. Note that |
Go v1.16 introduced module-aware commands by default. This version upgrade broke our http2 interop tests (see grpc#25660). Setting the go environment variable `GO111MODULE` to "auto" makes go tools behave as they did before the v1.16 change. Docs on the flag: https://golang.org/ref/mod#mod-commands Recent discussion on golang/go: golang/go#31997 (comment)
…de to go v1.16 (#25707) Go v1.16 introduced module-aware commands by default. This version upgrade broke our http2 interop tests (see #25660). Setting the go environment variable `GO111MODULE` to "auto" makes go tools behave as they did before the v1.16 change, but will not be compatible with v1.17. This PR introduces a minimal go.mod file for the interop test to appease go v1.16. Docs on the flag: https://golang.org/ref/mod#mod-commands Recent discussion on golang/go: golang/go#31997 (comment)
work for me thanks !!! |
I got |
Thank a lot!! |
Thanks for this, this worked for me. |
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
creating a file hello.go in /home/ubuntu/go/src/hello/
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
What did you expect to see?
go into /home/ubuntu/go/src/hello/
call go build
now i expected an created file hello (in go on windows it was hello.exe)
What did you see instead?
go: cannot find main module; see 'go help modules'
Does this issue reproduce with the latest release (go1.12.5)?
every time (but only under ubuntu@DESKTOP windows sub system. After installing go on windows directly, all was working fine. I was able to call go build and an hello.exe was created. After calling hello.exe an hello was printed out on cmd. But now under ubunto on wsl i can call go version, go get, go list... but go build throw this "go: cannot find main module; see 'go help modules'" error. I try to delete export GO111MODULE=on in .profile, but this issue is still here.
System details
The text was updated successfully, but these errors were encountered: