昨天我在 GO 中編碼,一切正常。今天我收到以下錯誤訊息:
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)
我已經洗掉了整個存盤庫,并使用昨天的版本進行了 git pull。我仍然無法編譯 go-code。我試圖編譯一個簡單的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"
uj5u.com熱心網友回復:
我不是 100% 確定,但它看起來像你go.mod的定義,Go 1.16但你正在嘗試運行具有Go 1.10依賴關系的代碼。
我會嘗試重新同步依賴項,例如洗掉go.sum并運行go mod tidy.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/457421.html
標籤:走
上一篇:使用Golang Gin Docker時“本地主機沒有發送任何資料”
下一篇:Cgo:對[C函式]的未定義參考
