GO:无法在任何地方找到包“ihelp/pkg/ihelp”

huangapple go评论83阅读模式
英文:

GO: cannot find package 'ihelp/pkg/ihelp' in any of

问题

昨天我在使用GO编码时一切正常。但是今天我遇到了以下错误信息:

main.go:10:2: 在以下位置找不到包"icalculate/pkg/idicalculateive":
    /usr/lib/go-1.10/src/icalculate/pkg/icalculate/algorithm(来自$GOROOT)
    /home/ademxkartal/go/src/icalculate/pkg/icalculate/algorithm(来自$GOPATH)

我已经删除了整个代码库,并使用昨天的版本进行了git pull。但是我仍然无法编译go代码。我尝试编译一个简单的hello.go代码,它可以正常工作。所以似乎GO编译器总体上是工作的。

有什么解决方案的想法吗?

这是我的go.mod文件内容:

module icalculate

go 1.16

这是我的模块结构(在Linux-Ubuntu上工作):

/calculatorGo
|---- go.mod
|---- go.sum
   |/pkg
      |/icalculate
         |/algorithm
         |---- algorithm.go

这是go env命令的输出:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ademxkartal/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ademxkartal/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build730659894=/tmp/go-build -gno-record-gcc-switches"
英文:

Yesterday I was coding in GO and everything worked well. Today I get the following error message:

main.go:10:2: cannot find package "icalculate/pkg/idicalculateive" in any of:
    /usr/lib/go-1.10/src/icalculate/pkg/icalculate/algorithm(from $GOROOT)
    /home/ademxkartal/go/src/icalculate/pkg/icalculate/algorithm(from $GOPATH)

I have deleted the whole repository and did a git pull with a version from yesterday. Still I cannot compile the go-code. I have tried to compile a simple hello.go code and this works. So it seems that the GO Compiler is working in general.

Any idea for a solution?

Here is my go.mod file:

module icalculate

go 1.16

here is my module structure (working on Linux-Ubuntu):

/calculatorGo
|---- go.mod
|---- go.sum
   |/pkg
      |/icalculate
         |/algorithm
         |---- algorithm.go

This is what go env prints out:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ademxkartal/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ademxkartal/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build730659894=/tmp/go-build -gno-record-gcc-switches"

答案1

得分: 1

我不是100%确定,但看起来你的go.mod文件是为Go 1.16定义的,但你正在尝试使用Go 1.10的依赖来运行代码。

我建议尝试重新同步依赖,例如删除go.sum文件并运行go mod tidy命令。

英文:

I'm not 100% sure but it looks like your go.mod is defined for Go 1.16 but you're trying to run the code with Go 1.10 dependencies.

I would try to re-sync the dependencies, e.g. remove go.sum and run go mod tidy.

huangapple
  • 本文由 发表于 2022年4月5日 21:45:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/71752907.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定