Docker “go build”的代码来自哪里?

Docker “go build”的代码来自哪里?,docker,go,go-modules,Docker,Go,Go Modules,因此,我有一个项目,我想使用Docker CLI代码的一些片段。它使用模块。Docker CLI不支持 奇怪的是,在某个时候我让它工作,但我不得不切换分支,现在我无法让它再次构建 我的go.mod如下所示: go 1.13 require ( github.com/docker/cli v0.0.0-20200129215115-2079e743c493 github.com/docker/docker v1.13.1 // indirect github.com/do

因此,我有一个项目,我想使用Docker CLI代码的一些片段。它使用模块。Docker CLI不支持

奇怪的是,在某个时候我让它工作,但我不得不切换分支,现在我无法让它再次构建

我的go.mod如下所示:

go 1.13

require (
    github.com/docker/cli v0.0.0-20200129215115-2079e743c493
    github.com/docker/docker v1.13.1 // indirect
    github.com/docker/go-connections v0.4.0 // indirect
    github.com/docker/go-units v0.4.0 // indirect
    github.com/imdario/mergo v0.3.8 // indirect
    github.com/mattn/go-shellwords v1.0.9 // indirect
    github.com/pelletier/go-toml v1.6.0 // indirect
    github.com/sirupsen/logrus v1.4.2
    github.com/spf13/afero v1.2.2 // indirect
    github.com/spf13/cast v1.3.1 // indirect
    github.com/spf13/cobra v0.0.5
    github.com/spf13/jwalterweatherman v1.1.0 // indirect
    github.com/spf13/pflag v1.0.5 // indirect
    github.com/spf13/viper v1.6.1
    github.com/xeipuuv/gojsonschema v1.2.0 // indirect
    golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
    golang.org/x/text v0.3.2 // indirect
    gopkg.in/ini.v1 v1.51.1 // indirect
    gopkg.in/yaml.v2 v2.2.7
    gotest.tools v2.2.0+incompatible // indirect
)
我尝试过删除供应商目录,我尝试过删除$(go env GOCACHE),我甚至尝试过删除pkg/mod目录。我尝试过在有和没有-mod=vendor的情况下构建。我甚至尝试过使用Dockerfile构建,不管有没有缓存

每次的结果都是一样的:

github.com/docker/cli/opts/config.go:15:12:undefined:swarm.ConfigReference

但是,这件事让我很吃惊,它在第15行的opts/config.go的任何版本上都没有这么说。它说的是
swarmtypes
,而不是
swarm
,这是正确的。在项目目录中对
swarm.ConfigReference
进行灰显不会产生任何结果。我还尝试过为config.go映射go构建的strace输出,除了这个错误之外没有其他结果。编辑:实际上strace正在截断路径,go build确实打开了文件。但是我检查了文件中显示为打开的绝对路径处的第15行,它显示
swarmtypes
而不是
swarm

go build从何处获取此代码

编辑:修复了,当go build报告实际类型而不是导入别名时,我正在跟踪重影。感谢下面的彼得

作为参考,这实际上构建了(注意,它使用了docker/docker的never版本):


请指出哪个库有您正在引用的源文件。您可以尝试使用相应的标记(在go.mod中指定)从github检出该库,然后检查文件的行是否正确。我添加了更多的路径。完整的路径显然取决于它是从pkg/mod还是从供应商处获取的,而不是结果方面的问题。问题是项目没有使用语义版本标记,go mod中的版本是添加master时go使用的版本。swarmtypes是的别名(请参阅config.go中的导入语句)。错误消息使用规范的包名,仅此而已。您必须找到该软件包的兼容版本才能成功生成。啊。。。这是有道理的。我确实注意到了导入别名,但错误地认为错误消息应该使用该别名(可以说应该)。我仍然不明白它为什么会在上周编译,但至少我不会再去追鬼了。谢谢:)
require (
    github.com/containerd/containerd v1.3.2 // indirect
    github.com/docker/cli v0.0.0-20200130152716-5d0cf8839492
    github.com/docker/distribution v2.7.1+incompatible // indirect
    github.com/docker/docker v1.4.2-0.20200201180422-513b207b002d // indirect
    github.com/docker/go-connections v0.4.0 // indirect
    github.com/docker/go-units v0.4.0 // indirect
    github.com/imdario/mergo v0.3.8 // indirect
    github.com/mattn/go-shellwords v1.0.9 // indirect
    github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
    github.com/opencontainers/image-spec v1.0.1 // indirect
    github.com/pelletier/go-toml v1.6.0 // indirect
    github.com/sirupsen/logrus v1.4.2
    github.com/spf13/afero v1.2.2 // indirect
    github.com/spf13/cast v1.3.1 // indirect
    github.com/spf13/cobra v0.0.5
    github.com/spf13/jwalterweatherman v1.1.0 // indirect
    github.com/spf13/pflag v1.0.5 // indirect
    github.com/spf13/viper v1.6.1
    github.com/xeipuuv/gojsonschema v1.2.0 // indirect
    golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
    golang.org/x/text v0.3.2 // indirect
    gopkg.in/ini.v1 v1.51.1 // indirect
    gopkg.in/yaml.v2 v2.2.7
    gotest.tools v2.2.0+incompatible // indirect
)