Unable to instal Sys Go package, I tried the normal way but it doesn't make sense. Please find below my Go env below

huangapple go评论84阅读模式
英文:

Unable to instal Sys Go package, I tried the normal way but it doesn't make sense. Please find below my Go env below

问题

我无法安装GoLang的Sys包。此外,以下是我的Go环境:

GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zahidk/.cache/go-build"
GOENV="/home/zahidk/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zahidk/gocode/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zahidk/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build2915773640=/tmp/go-build -gno-record-gcc-switches"

我尝试使用go get -u golang.org/x/sys和GOPATH/src/golang.org/x/sys从网站(https://pkg.go.dev/golang.org/x/sys#section-readme)安装sys包,但出现了一些问题。此外,在我的src目录中是我所有的GoLang文件。就是这样。

英文:

I cannot get the GoLang Sys package installed.
Unable to instal Sys Go package, I tried the normal way but it doesn't make sense. Please find below my Go env below

Furthermore, below is my Go env:

GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zahidk/.cache/go-build"
GOENV="/home/zahidk/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zahidk/gocode/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zahidk/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build2915773640=/tmp/go-build -gno-record-gcc-switches"

I tried using go get -u golang.org/x/sys and GOPATH/src/golang.org/x/sys from the website (https://pkg.go.dev/golang.org/x/sys#section-readme) to install the sys package but for some reason it doesn't work. Furthermore in my src directory are all my GoLang files. That's it.

答案1

得分: 1

您的go env显示您正在使用GOPATH模式(而不是模块):

GO111MODULE="auto"
GOPATH="/home/zahidk/gocode"
GOMOD=""

错误消息指示编辑器的GOPATH/home/zahidk/GoLang,与您的go env/home/zahidk/gocode)不同。这可能解释了为什么在通过编辑器进行开发时找不到下载的代码。

您应该确保在所有地方正确设置GOPATH环境变量,或者迁移到模块。

如果您没有特定的GOPATH需求,建议使用模块。模块使得管理依赖项更容易,并且很可能得到您的编辑器更好的支持。

英文:

Your go env indicates you are using GOPATH mode (instead of modules):

GO111MODULE="auto"
GOPATH="/home/zahidk/gocode"
GOMOD=""

The error message indicates the editor GOPATH is /home/zahidk/GoLang which
is different to your go env (/home/zahidk/gocode). This likely explains why the downloaded code is
not found when developing via the editor.

You should ensure the GOPATH environment variable is set correctly everywhere, or migrate to modules.

Using modules is recommended if you don't have a specific need for GOPATH. Modules make it easier to manage dependencies and are likely better supported by your editor.

huangapple
  • 本文由 发表于 2022年4月14日 05:40:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/71864105.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定