-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: "cannot find main module" when running 'go build' on a .go source file #28867
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
Is your Go installation broken by any chance? What does |
@mvdan, it is unlikely. I took the latest from https://golang.org/dl/. It is just go binary does not look for the modules inside $GOROOT.
|
@mvdan , specifically |
Certainly seems like your install is confused or weird. The command works for me in module mode.
/cc @bcmills |
GOMOD is only there if |
Here, the issue that |
If Whatever environment you're in, |
@mvdan , the below shows the standard library modules. For now, I will just switch back to
|
@greenpau, I'm not able to reproduce the problem with a From the previous comments it's not clear to me which commands you're running and whether module mode is actually enabled. Please post a complete transcript of the commands you invoked and their output (ideally within a
|
@bcmills, try taking a system where go was never present. Downlod the tar.gz file i mentioned above. Unpack it to /usr/local/go ... “tar xvzf” would do it automatically. ADD GOBIN GOROOT GOPATH. I am not cloning from git. i literally download it, unpacking it, and using it. |
@bcmills, i will the entire process shorlty. |
don't set the $GOROOT to go install path but |
maybe you should add a file named go.mod in your project |
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
)?What did you do?
I am compiling
caddy
.What did you expect to see?
Successful compilation.
What did you see instead?
This results in
go
not being able to find standard library modules, i.e. "bufio".The text was updated successfully, but these errors were encountered: