英文:
go mod vendor returns "all matched no packages"
问题
我正在尝试设置一个新的存储库,其中包含一些后端服务,名为backend
。我创建了该存储库,并将其克隆到/home/me/go/src/github.com/myrepo/backend
目录中。然后我执行了以下操作:
$ go mod init backend
go: 创建新的 go.mod 文件: module backend
go: 要添加模块要求和校验和:
go mod tidy
$ go mod tidy
go: 警告: "all" 未匹配到任何包
$ go get -u github.com/snowflakedb/gosnowflake
go: 正在下载...
$ go mod vendor
go: 警告: "all" 未匹配到任何包
在执行完所有这些操作后,/vendor/
目录中只包含modules.txt
文件,我的go.mod
文件如下所示:
$ cat go.mod
module backend
go 1.18
require (
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/Azure/azure-storage-blob-go v0.15.0 // indirect
github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect
github.com/aws/aws-sdk-go-v2 v1.16.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.12.1 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.5 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.4 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.9 // indirect
github.com/aws/smithy-go v1.11.2 // indirect
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
github.com/gabriel-vasile/mimetype v1.4.0 // indirect
github.com/google/flatbuffers v2.0.6+incompatible // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.15.4 // indirect
github.com/mattn/go-ieproxy v0.0.6 // indirect
github.com/pierrec/lz4/v4 v4.1.14 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/snowflakedb/gosnowflake v1.6.9 // indirect
golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 // indirect
golang.org/x/net v0.0.0-20220516155154-20f960328961 // indirect
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
}
当我执行go env
时,输出如下:
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-mod=vendor"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/me/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/me/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/me/go/src/github.com/myrepo/backend/go.mod"
GOWORK=""
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-build2382531553=/tmp/go-build -gno-record-gcc-switches"
我查看了一下,并找到了这个问题,但是由于我的模块没有遮盖标准库包,并且我还没有在其中编写任何 Golang 代码,所以我不认为这是问题的原因。所以,我的问题是:为什么我会收到这个警告,我应该怎么处理它,以及如何将go.mod
中引用的包缓存到/vendor/
目录中?
英文:
I'm trying to setup a new repo that will contain some backend services, named backend
. I created the repo, cloned it into /home/me/go/src/github.com/myrepo/backend
. I then did the following:
$ go mod init backend
go: creating new go.mod: module backend
go: to add module requirements and sums:
go mod tidy
$ go mod tidy
go: warning: "all" matched no packages
$ go get -u github.com/snowflakedb/gosnowflake
go: downloading...
$ go mod vendor
go: warning: "all" matched no packages
After all of this, the /vendor/
directory only contains modules.txt
and my go.mod
file looks like this:
$ cat go.mod
module backend
go 1.18
require (
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/Azure/azure-storage-blob-go v0.15.0 // indirect
github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect
github.com/aws/aws-sdk-go-v2 v1.16.3 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.12.1 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.4 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.5 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.4 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.9 // indirect
github.com/aws/smithy-go v1.11.2 // indirect
github.com/form3tech-oss/jwt-go v3.2.5+incompatible // indirect
github.com/gabriel-vasile/mimetype v1.4.0 // indirect
github.com/google/flatbuffers v2.0.6+incompatible // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.15.4 // indirect
github.com/mattn/go-ieproxy v0.0.6 // indirect
github.com/pierrec/lz4/v4 v4.1.14 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/snowflakedb/gosnowflake v1.6.9 // indirect
golang.org/x/crypto v0.0.0-20220516162934-403b01795ae8 // indirect
golang.org/x/net v0.0.0-20220516155154-20f960328961 // indirect
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
}
When I do go env
I get:
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-mod=vendor"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/me/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/me/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/me/go/src/github.com/myrepo/backend/go.mod"
GOWORK=""
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-build2382531553=/tmp/go-build -gno-record-gcc-switches"`
I looked around and found this question but, as my module doesn't shadow a standard library package and I haven't actually written any Golang code in it yet, I don't think this is the issue. So, my question is: why am I getting this warning, what should I do about it, and how can I cache packages referenced in go.mod
in /vendor/
?
答案1
得分: 3
对我来说有效的方法与构建标志无关,而是因为我的项目文件夹是一个软符号链接,而go mod tidy
无法跟随它。
据我了解,go mod tidy
不会跟随符号链接。
英文:
What worked for me had nothing to do with build flags, it was because my project folder was a soft symbolic link and go mod tidy
failed to follow it.
As far as I understand, go mod tidy
does not follow symbolic links.
答案2
得分: 2
正如@JimB指出的,核心问题是我还没有在模块中编写任何代码。一旦我添加了一些代码,警告就消失了。
英文:
As @JimB pointed out, the core issue was that I hadn't written any code in the module yet. As soon as I added some code, the warning went away.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论