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"
CodePudding user response:
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
.