Skip to content
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

go file package is not normal: `go: cannot find main module; see 'go help modules'` #28656

Closed
sun-wenming opened this issue Nov 8, 2018 · 3 comments

Comments

@sun-wenming
Copy link

@sun-wenming sun-wenming commented Nov 8, 2018

What version of Go are you using (go version)?

$ go version
go version go1.11.1 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

windows 7

go env Output
$ go env
```
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\go
set GOPROXY=
set GORACE=
set GOROOT=F:\Go
set GOTMPDIR=
set GOTOOLDIR=F:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\go\src\github.com\mecm\gin-blog\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build350633266=/tmp/go-build -gno-record-gcc-switches
```

What did you do?

I don't know. Maybe the computer is abnormally shut down.

What did you expect to see?

I am expect go: cannot find main module; see 'go help modules' this error dismiss.
But I don't know what caused

What did you see instead?

Two days ago the project is normal. But now the project every go file's package is error.
Like:
go: cannot find main module; see 'go help modules'

There is a go.mod file in the directory.From go env can see
set GOMOD=E:\go\src\github.com\mecm\gin-blog\go.mod
And go.mod file :

module github.com/mecm/gin-blog

require (
)

Thanks for you.

@sun-wenming sun-wenming closed this Nov 8, 2018
@sun-wenming sun-wenming reopened this Nov 8, 2018
@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Nov 10, 2018

Can you show us what are you doing so that you see this error ? Without concrete repro steps, it will be very hard for us to investigate further.

Thank you.

@sun-wenming

This comment has been minimized.

Copy link
Author

@sun-wenming sun-wenming commented Nov 11, 2018

Ok, I reinstalled the latest version of go. And create a hello world project.
image

Maybe is vscode go plugin(golint) problem.
I think I should close this issues. This may not be the problem of go language.

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Nov 11, 2018

Yes, I think your IDE is forcing your code to run in module mode. Hence you require a go.mod to exist.

@agnivade agnivade closed this Nov 11, 2018
@golang golang locked and limited conversation to collaborators Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.