Questions tagged [gopls]

gopls (pronounced "Go please") is the official Go language server developed by the Go team. It provides IDE features to any LSP-compatible editor.

https://pkg.go.dev/golang.org/x/tools/gopls

31 questions
5
votes
0 answers

How do I get gopls to work in NeoVim with lspconfig?

gopls in neovim, using lspconfig, does not seem to be working with any go file, even one that has a .git or go.mod file. My lspconfig can be found below, and after that is a LspInfo in a .go file showing it should be working. Any help would be much…
Darst King
  • 63
  • 4
5
votes
4 answers

Run and Debug unit tests with flags

I want to be able to run and debug unit tests within VS Code using the test explorer or code lens. But in order to run my tests, I need to add this flag: -ldflags "-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn" Therefore,…
ravi kumar
  • 1,548
  • 1
  • 13
  • 47
4
votes
0 answers

failed to load view for file:///D:/Go: err: go resolves to executable in current directory (.\go): stderr:

I use neovim and emacs on Windows10, Install through MSYS go install golang.org/x/tools/gopls@latest but emacs eglot & nvim lspconfig show: [eglot] Connected! Server `gopls' now managing `go-mode' buffers in project `Go'. [eglot] Server reports…
4
votes
0 answers

vscode: File not found, if clicking on build error ouput

I have a syntax error in write-file.go ├── go.mod └── write-file └── write-file.go I run write-file.go via shift-F9, and see this output in vscode: Starting: /home/guettli/go/bin/dlv dap --check-go-version=false --listen=127.0.0.1:42097…
guettli
  • 25,042
  • 81
  • 346
  • 663
3
votes
1 answer

This file is within module ".", which is not included in your workspace

I have a golang project which includes windows-specific code. When working on this project from vscode running on macOS, I'm getting the following warning opening file getFileCreationTime_windows.go: This file is within module ".", which is not…
vbezhenar
  • 11,148
  • 9
  • 49
  • 63
3
votes
2 answers

gopls disable struct auto-fill

I've written Golang code using Neovim+nvim-cmp. The language server gopls always auto-fills structs with initial values. For example: a := &MyStruct{} After saving the file, it modifies the struct to: a := &MyStruct{ Int1: 0, String2: "", …
aj3423
  • 2,003
  • 3
  • 32
  • 70
2
votes
2 answers

How to set the version of gopls to install with vscode Go extension?

I'm running go1.16, the latest gopls version is not compabtible with it. Confirmed it at https://github.com/golang/tools/blob/master/gopls/README.md. The installation fails with below error Installing golang.org/x/tools/gopls@latest FAILED { …
2
votes
0 answers

gopls extract function not working in neovim lsp

I am using Neovim v0.8.3 on Ubuntu 22.04.2 LTS. I have configured neovim LSP using mason plugin to use the Go language server gopls v0.13.1. I can confirm that the language server works for some functions. For example with my LSP config (see below),…
Ayub Malik
  • 2,488
  • 6
  • 27
  • 42
2
votes
1 answer

vscode go cannot organize imports when save code

I open the vscode language server gopls. And use Format Tool default(because prompts said others are not applicable when language server is enabled). and config set: "editor.formatOnSave": true, "editor.codeActionsOnSave": { …
xrui
  • 63
  • 2
2
votes
1 answer

Signature help docs missing

I want VSCode to function how it does in the VSCode (golang) demo, and how it used to work on a previous install. Can anybody provide the `setting.json needed for this? The VSCode demo, here & here, shows the docs (Signature Help) displayed next to…
2
votes
0 answers

how to resolve definition(GoDef) with gopls when I don't have go.mod file

I have a project, which doesn't use go.mod, and not follow the structure that project is under $GOPATH/src/.... It uses bazel and WORKSPACE file to manage depedencies. I use gopls in neovim, and it could not resolve imports like import…
DutchBro
  • 45
  • 4
2
votes
1 answer

How to solve the error ld: framework not found CoreFoundation while installing GOPLS?

I am using Apple M1 Pro 12.0.1 (21A559). with go version : go1.19.3 darwin/arm64 When I am trying to install gopls, I get the following error. go install -v…
2
votes
2 answers

VSCode: gopls: failed to install [read "https:/proxy.golang.org/@v/v0.1.0.zip": stream error: stream ID 9; NO_ERROR; received from peer]

While opening my Go project in VSCode or using the Go: install/update tools command I am getting the following error: 1 tools failed to install. gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: Command failed:…
Saikat
  • 14,222
  • 20
  • 104
  • 125
2
votes
1 answer

When should you set the $GOPATH variable?

Can anyone explain when to set $GOPATH? I know it's in the default, C:\Users\Username\go, location, but what if all my coding projects live in Z: ?
1
vote
1 answer

LSP-gopls in Sublime Text creates go directory in $HOME instead of a custom location

I am using Sublime Text with the LSP-gopls plugin for Go development and I have a custom GOPATH set: $HOME/Code/go instead of $HOME/go. However, every time I run Sublime Text, the directory go/pkg/mod/... is created in the $HOME directory. Normally,…
1
2 3