Closed bus710 closed 4 years ago
I know that the message You are neither in a module nor in your GOPATH is showing because I don't have go.mod in general but...
If I create a go.mod file for the project, it shows package not found warning. If I add redirect/require in that go.mod file, code completion doesn't work. Thus, I eventually deleted the go.mod to disable go module feature.
So, we may need a way to disable the warning when there is no go.mod file or...?
Thanks @bus710 again. From the trace, I can tell that
GOPATH="/usr/local/tinygo:/home/bus710/go"
And your workspace directory is /home/bus710/repo/flutter-webbluetooth/...
which is outside of any of the GOPATH
.
You are operating in the GOPATH mode, so please make sure to place your project directory under one of the GOPATH/src
. In this specific case, under /home/bus710/go/src
directory.
gopls
works both in GOPATH mode and modules mode.
If there is no go.mod
file and GO111MODULE
env var is not on, gopls
and also the go
command expect to work in the GOPATH
mode. In the GOPATH mode, the repository should be located inside the GOPATH mode.
The go.mod
file makes sense only in the module mode. In the module mode, the go
command and gopls
retrieve dependencies from the module cache. I don't know if tinygo
is compatible with modules mode yet.
I think this is working as intended. Thanks again for the report!
Right, I see the point that I haven't thought a while since I started using modules. Thanks for your advise! Let me close this.
Tiny-go and You are neither in a module nor in your GOPATH
Context:
Summary:
Please answer these questions before submitting your issue. Thanks!
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gocode -v
orcode-insiders -v
to get version of VS Code or VS Code Insidersgo env GOOS GOARCH
to get the operating system and processor architecture detailsShare the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file. Share all the settings with thego.
or["go"]
prefixes.User setting:
Workspace setting:
Describe the bug
I saw other tickets about GOPATH and gopls, but this ticket can be something new since here we have two different go compilers (Go and Tiny-go).
Vscode-go does code completion well with the workspace config attached (.vscode/settings.json) but I see the warning dialog of gopls that says as the title whenever I add a dot after a struct so that it is guessed as an issue of gopls as the link filed as context in the beginning. Gopls log is also attached below but please let me know if other information can be helpful to tackle the problem.
Gopls log: