登录
首页 >  Golang >  Go问答

Go Tools 安装成功,但没有在 $GOPATH/bin 中显示

来源:stackoverflow

时间:2024-03-07 08:09:25 379浏览 收藏

小伙伴们对Golang编程感兴趣吗?是否正在学习相关知识点?如果是,那么本文《Go Tools 安装成功,但没有在 $GOPATH/bin 中显示》,就很适合你,本篇文章讲解的知识点主要包括。在之后的文章中也会多多分享相关知识点,希望对大家的知识积累有所帮助!

问题内容

我在vscode中安装了go tools,终端显示工具安装成功:

tools environment: gopath=/home/spindrift/go
installing 1 tool at /home/spindrift/go/bin in module mode.
  gopls

installing golang.org/x/tools/gopls (gopls) succeeded

all tools successfully installed. you are ready to go :).

但是安装完vscode后一直显示gopls已被查询但缺少

所以我看了一下$gopath/bin,里面只有dlv-dap

我检查我配置的工具:

checking configured tools....
gobin: undefined
toolsgopath: 
gopath: /home/spindrift/go
goroot: /usr/local/go
path: /usr/local/go/bin:/home/spindrift/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/program files/windowsapps/microsoft.windowsterminal_1.12.10732.0_x64__8wekyb3d8bbwe:/mnt/c/windows:/mnt/c/windows/system32:/mnt/c/windows/system32/wbem:/mnt/c/windows/system32/windowspowershell/v1.0/:/mnt/c/windows/system32/openssh/:/mnt/c/developtools/maven/apache-maven-3.2.5/bin:/mnt/c/developtools/mingw64/mingw64/bin:/mnt/c/developtools/matlab2018a/runtime/win64:/mnt/c/developtools/matlab2018a/bin:/mnt/c/developtools/lingo/:/mnt/c/developtools/mongodb/server/bin:/mnt/c/developtools/git/cmd:/mnt/c/developtools/mysql/bin:/mnt/c/developtools/anaconda3:/mnt/c/developtools/anaconda3/scripts:/mnt/c/developtools/anaconda3/library/bin:/mnt/c/windows/system32:/mnt/c/developtools/go/bin:/mnt/c/developtools/scala/bin:/mnt/c/program files/dotnet/:/mnt/c/users/libra/appdata/local/microsoft/windowsapps:/mnt/c/developtools/vscode/microsoft vs code/bin:/mnt/c/software/bandizip/:/mnt/c/users/libra/appdata/roaming/npm:/mnt/c/developtools/nodejs:/mnt/c/users/libra/go/bin:/mnt/c/users/libra/.dotnet/tools:/snap/bin
path (vscode launched with): /home/spindrift/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/program files/windowsapps/microsoft.windowsterminal_1.12.10732.0_x64__8wekyb3d8bbwe:/mnt/c/windows:/mnt/c/windows/system32:/mnt/c/windows/system32/wbem:/mnt/c/windows/system32/windowspowershell/v1.0/:/mnt/c/windows/system32/openssh/:/mnt/c/developtools/maven/apache-maven-3.2.5/bin:/mnt/c/developtools/mingw64/mingw64/bin:/mnt/c/developtools/matlab2018a/runtime/win64:/mnt/c/developtools/matlab2018a/bin:/mnt/c/developtools/lingo/:/mnt/c/developtools/mongodb/server/bin:/mnt/c/developtools/git/cmd:/mnt/c/developtools/mysql/bin:/mnt/c/developtools/anaconda3:/mnt/c/developtools/anaconda3/scripts:/mnt/c/developtools/anaconda3/library/bin:/mnt/c/windows/system32:/mnt/c/developtools/go/bin:/mnt/c/developtools/scala/bin:/mnt/c/program files/dotnet/:/mnt/c/users/libra/appdata/local/microsoft/windowsapps:/mnt/c/developtools/vscode/microsoft vs code/bin:/mnt/c/software/bandizip/:/mnt/c/users/libra/appdata/roaming/npm:/mnt/c/developtools/nodejs:/mnt/c/users/libra/go/bin:/mnt/c/users/libra/.dotnet/tools:/snap/bin:/usr/local/go/bin

    go: /usr/local/go/bin/go: go version go1.18.1 linux/amd64

    gopkgs: not installed
    go-outline: not installed
    gotests:    not installed
    gomodifytags:   not installed
    impl:   not installed
    goplay: not installed
    dlv:    not installed
    dlv-dap:    /home/spindrift/go/bin/dlv-dap: go1.18.1
        path    github.com/go-delve/delve/cmd/dlv
        mod github.com/go-delve/delve   v1.8.3-0.20220413222856-313815782614    h1:j92zq5+vc+zzd0gn69rxvuuc3orkgcigmurmpusci4i=
        dep github.com/cilium/ebpf  v0.7.0  h1:1k/q3atgxsxrdrmpfh8d7yk0gfqvsekzax9dqzvs56k=
        dep github.com/cosiner/argv v0.1.0  h1:bvdiel32lwhukgjkp87btepenzrrhujajs/8yzaqcxg=
        dep github.com/cpuguy83/go-md2man/v2    v2.0.0  h1:eouds0afbrsxaz9yq9jdu/mz2sxgt1/2yynng4pglym=
        dep github.com/derekparker/trie v0.0.0-20200317170641-1fdf38b7b0e9  h1:g765idcq7bp5opdrpkxk+4v3yfkgv9igfuhewz/x/zy=
        dep github.com/go-delve/liner   v1.2.2-1    h1:0hgpzh6vji6lftlxuhfcx9pebaluzdzps2owdmrrsuk=
        dep github.com/google/go-dap    v0.6.0  h1:y1rhgutv3r8y6sxq2dtgrmyrfb2hsqyfvws7jucrzx4=
        dep github.com/hashicorp/golang-lru v0.5.4  h1:ydjusn29qi/das2io9m0bhnibxpeyuchsjmw+ljfytc=
        dep github.com/mattn/go-isatty  v0.0.3  h1:ns/ykhmwi7g9o+8a448secju3nsmbxjfqqkl0upe1ji=
        dep github.com/mattn/go-runewidth   v0.0.13 h1:ltgmdsbayt5dmk6onov7euif1weifacxld6ypu4osgu=
        dep github.com/rivo/uniseg  v0.2.0  h1:s1pd9wezbujdfmownwbpi7bj8tnftyuimj/0wqi72jy=
        dep github.com/russross/blackfriday/v2  v2.0.1  h1:lpqvate+huhnfhj/0lc98eswrz8afy9tm/0rk8m9o+q=
        dep github.com/shurcool/sanitized_anchor_name   v1.0.0  h1:pdmoco6wvbs+7yrjymort4/bmy5iyyjws/koiwx8mho=
        dep github.com/sirupsen/logrus  v1.6.0  h1:ubcnelsrwanuumsngslymtmgbb23qdr5dg+6x6oo89i=
        dep github.com/spf13/cobra  v1.1.3  h1:xghbfqpkxzxp3c/f3n5ddpabdklj4ze4bwqi362l53m=
        dep github.com/spf13/pflag  v1.0.5  h1:iy+vfuocp1a+8yfto/drg2cj5u0yrob7fzw3dkv/jxa=
        dep go.starlark.net v0.0.0-20200821142938-949cc6f4b097  h1:yirmxxgg+pg26t1fjq+iajaaukwmc9cmgfrtoeuwddg=
        dep golang.org/x/arch   v0.0.0-20190927153633-4e8777c89be4  h1:qlvatys7jbozmvaf+cnjb90wd/bekvhnixfkt4qahvi=
        dep golang.org/x/sys    v0.0.0-20211117180635-dee7805ff2e1  h1:kwrahlwj0dubzwq238v+uod/3ez8b2k5rysuhbqvzmi=
        dep gopkg.in/yaml.v2    v2.4.0  h1:d8xgwecy7cyvx+y2n4sbz93jn9jrvxdiyyo8ctfukay=
        build   -compiler=gc
        build   cgo_enabled=1
        build   cgo_cflags=
        build   cgo_cppflags=
        build   cgo_cxxflags=
        build   cgo_ldflags=
        build   goarch=amd64
        build   goos=linux
        build   goamd64=v1
    
    staticcheck:    not installed
    gopls:  not installed

看来我安装go tools失败了。尝试了几次,问题还是没有解决。

这是我的 go env

GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/spindrift/.cache/go-build"
GOENV="/home/spindrift/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/spindrift/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/spindrift/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1163911802=/tmp/go-build -gno-record-gcc-switches"

正确答案


这是 go 扩展中的一个错误,在使用 go 1.18 时出现。该问题已在最新版本的 vscode-go 中修复,详细信息请参见[1]和[2]。

更新 vscode go 扩展 (vscode-go) 应该可以解决您的问题(就像它为我所做的那样)。

[1]https://github.com/golang/vscode-go/issues/2143

[2]https://github.com/golang/vscode-go/commit/656865daa974f43e8e88310e5076f3f0c4936c73

以上就是《Go Tools 安装成功,但没有在 $GOPATH/bin 中显示》的详细内容,更多关于的资料请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>