我正在尝试构建Go项目,但出现此特定错误:
main.go:11:5: cannot find package "github.com/vharitonsky/iniflags" in any of:
/usr/local/go/src/github.com/vharitonsky/iniflags (from $GOROOT)
/root/go/src/github.com/vharitonsky/iniflags (from $GOPATH)
main.go:12:5: cannot find package "go-server-server/go" in any of:
/usr/local/go/src/go-server-server/go (from $GOROOT)
/root/go/src/go-server-server/go (from $GOPATH)
这是我的围护环境:
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/var/<uname>/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/var/<uname>/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/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-build544503184=/tmp/go-build -gno-record-gcc-switches"
$ go version
go version go1.11.5 linux/amd64
让我感到困惑的是,即使我的GOPATH是/var/<uname>/go
,为什么Go会在/root/go...
处查看这些软件包?我该如何解决?