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

x/tools/gopls: compilation error pop-up #41140

Closed
PICKQUE opened this issue Aug 31, 2020 · 8 comments
Closed

x/tools/gopls: compilation error pop-up #41140

PICKQUE opened this issue Aug 31, 2020 · 8 comments

Comments

@PICKQUE
Copy link

@PICKQUE PICKQUE commented Aug 31, 2020

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

$ go version 1.15

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\admin\AppData\Local\go-build
set GOENV=C:\Users\admin\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=E:\Go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=E:\Go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=D:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\Go\project\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 -fmessage-length=0 -fdebug-prefix-map=C:\Users\admin\AppData\Local\Temp\go-build752024006=/tmp/go-build -gno-record-gcc-switches

What did you do?

i'm using the vscode as my go-editor, but found the error massage when i try to save this file(ctrl + s)
image

What did you expect to see?

it'not error message

@stamblerre stamblerre changed the title vscode-go script error message x/tools/gopls: compilation error pop-up Aug 31, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 31, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Aug 31, 2020

Can you please share your gopls logs? Information on how to capture them can be found here.

@PICKQUE
Copy link
Author

@PICKQUE PICKQUE commented Sep 1, 2020

gopls error log
like this
image

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 1, 2020

You have a typo in your "go.languageServerFlags" settings - it should be "serve" not "server".

@PICKQUE
Copy link
Author

@PICKQUE PICKQUE commented Sep 2, 2020

the error message like this? Is this because of my file upload naming problem?

[Trace - 09:56:01.871 AM] Sending request 'textDocument/codeAction - (57)'.
Params: {"textDocument":{"uri":"file:///e%3A/Go/gochat/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":46,"character":0}},"context":{"diagnostics":[],"only":["source.organizeImports"]}}


[Trace - 09:56:01.872 AM] Received response 'textDocument/codeAction - (57)' in 1ms.
Result: null


[Trace - 09:56:01.874 AM] Sending request 'textDocument/formatting - (58)'.
Params: {"textDocument":{"uri":"file:///e%3A/Go/gochat/main.go"},"options":{"tabSize":4,"insertSpaces":false}}


[Trace - 09:56:01.874 AM] Received response 'textDocument/formatting - (58)' in 0ms.
Result: []


[Trace - 09:56:01.915 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"uri":"file:///e%3A/Go/gochat/main.go","version":14}}


[Trace - 09:56:02.011 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2020/09/02 09:56:02 go/packages.Load: 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'\n\n\tsnapshot=19\n\tdirectory=\n\tquery=[./]\n\tpackages=0\n"}


[Trace - 09:56:02.011 AM] Received notification 'window/showMessage'.
Params: {"type":1,"message":"The code in the workspace failed to compile (see the error message below).\nIf you believe this is a mistake, please file an issue: https://github.com/golang/go/issues/new.\ngo [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./]: exit status 1: go: cannot find main module; see 'go help modules'\n: packages.Load error"}


[Trace - 09:56:02.011 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"2020/09/02 09:56:02 The code in the workspace failed to compile (see the error message below).\nIf 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'\n: packages.Load error\n\tsnapshot=19\n\tdirectory=file:///E:/Go\n"}


[Error - 上午9:56:02] 2020/09/02 09:56:02 go/packages.Load: 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'

	snapshot=19
	directory=
	query=[./]
	packages=0

[Error - 上午9:56:02] 2020/09/02 09:56:02 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
	snapshot=19
	directory=file:///E:/Go

[Trace - 09:56:31.873 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/09/02 09:56:31 background imports cache refresh starting\n"}


[Info  - 上午9:56:31] 2020/09/02 09:56:31 background imports cache refresh starting

[Trace - 09:56:31.953 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/09/02 09:56:31 background refresh finished after 80.0042ms\n"}
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 2, 2020

This issue looks different - please make sure to open your workspace to your module root (the directory containing the go.mod file). In your case, I think this would be the E:\Go\gochat directory. This is currently a requirement of gopls, but we're working on changing that in future versions.

@PICKQUE
Copy link
Author

@PICKQUE PICKQUE commented Sep 2, 2020

but i have this mod file
image

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 2, 2020

Yes, but you need to open the gochat directory in VS Code, not the top-level directory. This is a current limitation of gopls that we are working on addressing. You can also use View -> Add Folder to Workspace and add the gochat directory this way.

@PICKQUE
Copy link
Author

@PICKQUE PICKQUE commented Sep 2, 2020

yes it's working and thankyou very much and hope you have a good sleep

@stamblerre stamblerre closed this Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.