The "gopls" command is not available. Run "go get -v golang.org/x/tools/gopls" to install.
I'm running on go 1.14. Not sure what will happen, if I follow the instruction.
Installing 1 tool at the configured GOBIN: /usr/local/go/bin in module mode.
gopls
Installing golang.org/x/tools/gopls FAILED
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "/usr/local/go/bin/go get -v golang.org/x/tools/gopls",
"stdout": "",
"stderr": "go: downloading golang.org/x/tools/gopls v0.6.9\ngo: golang.org/x/tools/gopls upgrade => v0.6.9\ngo: downloading golang.org/x/tools v0.1.1-0.20210319172145-bda8f5cee399
...
1 tools failed to install.
gopls: failed to install gopls(golang.org/x/tools/gopls): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/gopls
go: downloading golang.org/x/tools/gopls v0.6.9
go: golang.org/x/tools/gopls upgrade => v0.6.9
go: downloading golang.org/x/tools v0.1.1-0.20210319172145-bda8f5cee399
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading honnef.co/go/tools v0.1.1
go: downloading golang.org/x/mod v0.4.1
golang.org/x/mod/semver
...
go get golang.org/x/tools/gopls: copying /var/folders/gq/bwl3jmx562x5twchgxvb6mlh0000gn/T/go-build703164122/b001/exe/a.out: open /usr/local/go/bin/gopls: permission denied
no output
I had the same problem and solved it with:
go install -v golang.org/x/tools/gopls#latest
if you get the error:
x\tools#v0.1.13-0.20220811140653-b901dff69f70\internal\lsp\source\hover.go:23:2: module golang.org/x/text#latest found (v0.3.7), but does not contain package golang.org/x/text/unicode/runenames
try using:
go clean -modcache
go install -v golang.org/x/tools/gopls#latest
The extension depends on other tools to provide necessary features. gopls is one of the core tools necessary to provide language features like code completion, navigation, search, etc for go language. See the list of tools the extension depends on: https://github.com/golang/vscode-go/blob/master/docs/tools.md
"Install" will install the 'gopls'.
"Install All" will install all the missing tools.
If you are using go1.14, either click the button (or run "Go: Install/Update Tools" command from the command palette) or, install tools in module mode with the following command (not just go get because with go1.14, the go command will try to install the tool in GOPATH mode which isn't what you want.)
cd /tmp/
GO111MODULE=on go get golang.org/x/tools/gopls
Here I solved using the command brew install gopls
Related
When i run my Go code in VSCode i needed install some modules. All modules normal downloaded and installing but 2 moduled (dlv & gopls) filed.
Tools environment: GOPATH=/home/user/project
Installing 2 tools at /home/user/project/bin in module mode.
dlv
gopls
Installing github.com/go-delve/delve/cmd/dlv#latest FAILED
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "/usr/local/go/bin/go install -v github.com/go-delve/delve/cmd/dlv#latest",
"stdout": "",
"stderr": "go: downloading golang.org/x/sys v0.0.0-20220908164124-27713097b956\n../pkg/mod/github.com/sirupsen/logrus#v1.6.0/terminal_check_unix.go:6:8: golang.org/x/sys#v0.0.0-20220908164124-27713097b956: read \"https:/proxy.golang.org/#v/v0.0.0-20220908164124-27713097b956.zip\": read tcp 192.168.1.125:37454->209.85.233.141:443: read: connection reset by peer\n"
}
Installing golang.org/x/tools/gopls#latest FAILED
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "/usr/local/go/bin/go install -v golang.org/x/tools/gopls#latest",
"stdout": "",
"stderr": "go: downloading golang.org/x/sys v0.2.0\n../pkg/mod/golang.org/x/tools#v0.3.1-0.20221213193459-ca17b2c27ca8/go/packages/external.go:15:2: golang.org/x/sys#v0.2.0: read \"https:/proxy.golang.org/#v/v0.2.0.zip\": read tcp 192.168.1.125:53838->142.250.185.209:443: read: connection reset by peer\n"
}
2 tools failed to install.
dlv: failed to install dlv(github.com/go-delve/delve/cmd/dlv#latest): Error: Command failed: /usr/local/go/bin/go install -v github.com/go-delve/delve/cmd/dlv#latest
go: downloading golang.org/x/sys v0.0.0-20220908164124-27713097b956
../pkg/mod/github.com/sirupsen/logrus#v1.6.0/terminal_check_unix.go:6:8: golang.org/x/sys#v0.0.0-20220908164124-27713097b956: read "https:/proxy.golang.org/#v/v0.0.0-20220908164124-27713097b956.zip": read tcp 192.168.1.125:37454->209.85.233.141:443: read: connection reset by peer
gopls: failed to install gopls(golang.org/x/tools/gopls#latest): Error: Command failed: /usr/local/go/bin/go install -v golang.org/x/tools/gopls#latest
go: downloading golang.org/x/sys v0.2.0
../pkg/mod/golang.org/x/tools#v0.3.1-0.20221213193459-ca17b2c27ca8/go/packages/external.go:15:2: golang.org/x/sys#v0.2.0: read "https:/proxy.golang.org/#v/v0.2.0.zip": read tcp 192.168.1.125:53838->142.250.185.209:443: read: connection reset by peer
In the terminal the code builds fine. I think the problem is in VSCode, but googling didn't turn up anything.
I'm new to Go and trying to import the jwx package found here. Using the following sample code. On Windows, I execute the following command in the root of my source.
go get github.com/lestrrat-go/jwx
go get github.com/lestrrat-go/jwx/jwk
The command "get go" passes:
but when I go into the import section of the go file I get the following error:
Any ideas?
Have a look at a fresh full working session below, hope it can help you find what it's wrong with your procedure.
Make sure we are using a recent Go version
$ go version
go version go1.18.1 linux/amd64
Make sure that GOPATH is unset
$ echo $GOPATH
$
Create and initialize a new module
$ mkdir /tmp/example
$ cd /tmp/example
$ go mod init example.com/example
go: creating new go.mod: module example.com/example
$
Write the test program
$ cat > main.go
package main
import (
"fmt"
"github.com/lestrrat-go/jwx/v2/jwk"
)
func main() {
fmt.Println(jwk.Cache{})
}
$
Download required modules
$ go mod tidy
go: downloading github.com/lestrrat-go/jwx/v2 v2.0.0
go: downloading github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1
go: downloading github.com/lestrrat-go/blackmagic v1.0.1
go: downloading github.com/lestrrat-go/httprc v1.0.1
go: downloading github.com/lestrrat-go/iter v1.0.2
go: downloading github.com/lestrrat-go/option v1.0.0
go: downloading github.com/goccy/go-json v0.9.7
go: downloading golang.org/x/crypto v0.0.0-20220214200702-86341886e292
go: downloading github.com/lestrrat-go/httpcc v1.0.1
go: downloading github.com/stretchr/testify v1.7.1
go: downloading gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
go: downloading github.com/davecgh/go-spew v1.1.0
go: downloading github.com/pmezard/go-difflib v1.0.0
$
Run the test program
$ go run example.com/example
{<nil>}
$
I get the following error on vscode on Monterey with golang
Tools environment: GOPATH=/Users/randolphhill/devgo/workspace, GOBIN=/Users/randolphhill/devgo/workspace/bin
Installing 1 tool at the configured GOBIN: /Users/randolphhill/devgo/workspace/bin in module mode.
dlv
Installing github.com/go-delve/delve/cmd/dlv#latest FAILED
{
"killed": false,
"code": 2,
"signal": null,
"cmd": "/usr/local/opt/go/libexec/bin/go install -v github.com/go-delve/delve/cmd/dlv#latest",
"stdout": "",
"stderr": "go: cannot find GOROOT directory: /usr/local/opt/libexec\n"
}
1 tools failed to install.
dlv: failed to install dlv(github.com/go-delve/delve/cmd/dlv#latest): Error: Command failed: /usr/local/opt/go/libexec/bin/go install -v github.com/go-delve/delve/cmd/dlv#latest
go: cannot find GOROOT directory: /usr/local/opt/libexec
That seems like an odd GOROOT path. Have you tried uninstalling and reinstalling Go?
I have go installed and it is located at /usr/local/go/bin/go not /usr/local/opt/go/libexec/bin/go.
From the Go website: https://go.dev/doc/manage-install; The default install location is usually /usr/local/go.
While running:
brew install
I am receiving:
brew command not found
and while running:
go get -u github.com/golang/protobuf/protoc-gen-go
I am receiving:
go: found github.com/golang/protobuf/protoc-gen-go in github.com/golang/protobuf v1.4.2
go: google.golang.org/protobuf upgrade => v1.25.0
go: updating go.sum: open /usr/local/go/src/go.sum: permission denied
ksetti-mac-mini-4#KSETTis-Mini src % go get -u github.com/golang/protobuf/protoc-gen-go
go: found github.com/golang/protobuf/protoc-gen-go in github.com/golang/protobuf v1.4.2
go: google.golang.org/protobuf upgrade => v1.25.0
go: updating go.sum: open /usr/local/go/src/go.sum: permission denied
What am I doing wrong?
Is your GOPATH set to something like '~/go'? It's trying to write to a soure directory that you don't seem to have access to.
This is from my .bashrc
# GoLang Configurations
export GOPATH=$HOME/Golang
export PATH=$PATH:$GOPATH/bin
I successfully installed go1.6.2 with gvm and used global pkgset.
I am trying to install gocode package with gvm, but go get not working.
I guess gvm is not really stable yet?
➜ ~ gvm use 1.6.2
Now using version go1.6.2
➜ ~ gvm pkgset use global
Now using version go1.6.2#global
➜ ~ go get -u github.com/nsf/gocode
➜ ~ go list
can't load package: package .: no buildable Go source files in /Users/seoyoochan
➜ ~ go install gocode
can't load package: package gocode: cannot find package "gocode" in any of:
/Users/seoyoochan/.gvm/gos/go1.6.2/src/gocode (from $GOROOT)
/Users/seoyoochan/.gvm/pkgsets/go1.6.2/global/src/gocode (from $GOPATH)
/Users/seoyoochan/.gvm/pkgsets/go1.6.2/global/src/gocode
when you go get some package, if it has buildable source, the go install commang will automatically run inside the package directory, so you don't need to go install gocode. just type gocode to check.
If you want to install it manually, you have to go to the directory first
cd $GOPATH/src/github.com/nsf/gocode
go install
Also you cannot perform go list outside package directory
cd $GOPATH/src/github.com/nsf/gocode
go list