【发布时间】:2019-06-10 22:40:09
【问题描述】:
我已关注 this guide 在 Ubuntu 16.04 上安装 Go。但是,当我为 Go 应用程序 (go get github.com/src-d/enry/cmd/enry) 关注 installation instructions 时,我收到以下错误:
package github.com/src-d/enry/v2: cannot find package "github.com/src-d/enry/v2" in any of:
/usr/local/go/src/github.com/src-d/enry/v2 (from $GOROOT)
/root/work/src/github.com/src-d/enry/v2 (from $GOPATH)
package github.com/src-d/enry/v2/data: cannot find package "github.com/src-d/enry/v2/data" in any of:
/usr/local/go/src/github.com/src-d/enry/v2/data (from $GOROOT)
/root/work/src/github.com/src-d/enry/v2/data (from $GOPATH)
这是go env的输出:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/work"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
我做错了什么?
注意:我对如何在 Go 中编程的知识完全为零,我只是想安装一个 CLI 应用程序。
【问题讨论】:
-
这看起来可能是模块导入路径,但您使用的是 GOPATH。尝试设置
GO111MODULE=on。 -
@JimB 在运行
export GO111MODULE="on"后,我仍然得到同样的错误。echo $GO111MODULE确实返回on -
按照 golang.org 上的官方方式安装 Go。
-
@APixelVisuals 你能分享你的导入声明吗?
-
你的 gopath 在
/root上你确定它可以被go get读/写吗?
标签: go installation failed-installation