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?