could not import <package> current file is not included in a workspace module
Ich versuche gerade ein Projekt mit „ebitengine“ zu erstellen, dazu habe ich den folgenden Befehl ausgeführt
go mod init PROJECT (in the directory same as the code) go work init go get -u github.com/hajimehoshi/ebiten/v2 go mod init PROJECT (Again because the error was still being shown) go work init (Again because the error was still being shown)
Die Ausgabe von „go env“ ist:
GO111MODULE="auto" GOARCH="amd64" GOBIN="/home/user/go/bin" GOCACHE="/home/user/.cache/go-build" GOENV="/home/user/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/user/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/user/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.20.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/user/Desktop/learnings/go/14SwitchCase/go.mod" GOWORK="/home/user/Desktop/learnings/go/go.work" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1152057857=/tmp/go-build -gno-record-gcc-switches"
export GOPATH=$HOME/go export GOBIN=$GOPATH/bin export PATH=${PATH}:$GOBIN
Das obige ist der detaillierte Inhalt von„