dongxingqiu7943 2018-10-08 17:39
浏览 42

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

First off, I have no experience with go, I'm just trying to build a project from github.

My problem: When I use go build in a cloned go project I get a bunch of errors like this:

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)

What happened: I broke everything because I started deleting random directories hoping to fix a different issue I was having. I deleted my ~/go directory, and the ~/.cache/go-build directory.

What I've tried: So far, besides the deletions that caused the problem, I've tried go clean -cache -modcache; Adding the -r flag produces the same errors as above. go build -a also produces the same errors. I have also tried reinstalling go with pacman -S go.

My go env is:

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"

I know I was doing things unexpected, but I'm surprised Go is struggling here. How can I make Go realize that the packages are not present and that it should fix that by downloading them? Or, how can I clean my environment to remove whatever artifacts are still present that are making Go think the packages should still exist?

  • 写回答

1条回答 默认 最新

  • dongyinglan8707 2018-10-08 18:25
    关注

    After reading up to respond to comments, I stumbled upon the go mod verify command which appears to have fixed my issues.

    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数