强制重新下载/完全干净的环境

时间:2018-10-08 17:39:24

标签: go build

首先,我没有使用go的经验,我只是想从github构建一个项目。

我的问题:当我在克隆的go项目中使用go build时,会出现很多这样的错误:

transform.go:28:2: cannot find package "github.com/disintegration/imaging" in any of:
        /usr/lib/go/src/github.com/disintegration/imaging (from $GOROOT)
        /home/marcus/go/src/github.com/disintegration/imaging (from $GOPATH)
imageproxy.go:34:2: cannot find package "github.com/gregjones/httpcache" in any of:
        /usr/lib/go/src/github.com/gregjones/httpcache (from $GOROOT)
        /home/marcus/go/src/github.com/gregjones/httpcache (from $GOPATH)
transform.go:29:2: cannot find package "github.com/muesli/smartcrop" in any of:
        /usr/lib/go/src/github.com/muesli/smartcrop (from $GOROOT)
        /home/marcus/go/src/github.com/muesli/smartcrop (from $GOPATH)

发生了什么:我破坏了所有事情,因为我开始删除随机目录,希望解决我遇到的其他问题。我删除了~/go目录和~/.cache/go-build目录。

我尝试过的方法:到目前为止,除了导致问题的删除操作外,我还尝试过go clean -cache -modcache;添加-r标志会产生与上述相同的错误。 go build -a也会产生相同的错误。我也尝试过使用pacman -S go重新安装go。

我的go env是:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/marcus/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/marcus/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
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-build315222728=/tmp/go-build -gno-record-gcc-switches"

我知道我做的事情出乎意料,但是我很惊讶Go在这里挣扎。我如何使Go意识到不存在这些软件包,并且应该通过下载来解决这些问题?或者,如何清洁环境以删除仍使Go认为软件包仍然存在的任何工件?

1 个答案:

答案 0 :(得分:0)

在阅读并回应评论后,我偶然发现了go mod verify命令,该命令似乎已解决了我的问题。