So I have a project that I want to use some bit of pieces of the Docker CLI code for. It uses modules. Docker CLI does not.
The weird thing is, that at some point I had this working, but I had to switch branches and now I cannot get it to build again.
My go.mod looks like this:
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
)
I have tried removing the vendor directory, I have tried removing $(go env GOCACHE), I have even tried removing the pkg/mod directory. I have tried building with and without -mod=vendor. I have even tried building using a Dockerfile, with and without --no-cache.
Every time, the result is the same:
github.com/docker/cli/opts/config.go:15:12: undefined: swarm.ConfigReference
But, and this is the thing that boggles me, that is not what it says on any version of opts/config.go on line 15. It says swarmtypes
instead of swarm
which is correct. Grepping for swarm.ConfigReference
in the project directory yields no results. I also tried grepping strace output of go build for config.go, no results other than this error. Edit: actually strace was truncating the path, go build does actually open the file. But I check line 15 in the file at the absolute path shown to be opened and it says swarmtypes
not swarm
.
Where is go build getting this code from?
Edit: fixed, I was chasing ghosts as go build was reporting the actual type instead of the import alias. Thanks to Peter below.
For reference, this actually builds (notice it uses a never version of docker/docker):
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
)