How do I find out the source of this old Sirupsen module?
Use the Go 1.13 beta (go get golang.org/dl/go1.13beta1 && go1.13beta1 download
) or even better, try the latest Go on tip / master (go get golang.org/dl/gotip && gotip download
).
Go 1.13 has improved error messages in general. It should help in your case, including most likely showing the import chain leading up to the error.
For example:
$ gotip build .
go: example.com/temp/mod imports
github.com/docker/libcompose/docker imports
github.com/Sirupsen/logrus: github.com/Sirupsen/[email protected]: parsing go.mod:
module declares its path as: github.com/Sirupsen/logrus
but was required as: github.com/sirupsen/logrus
In that example, you can see that docker/libcompose/docker
is importing the old and now incorrect uppercase version of Sirupsen/logrus
.
The most common reason people see a Sirupsen/logrus
vs. sirupsen/logrus
case mismatch is when importing github.com/docker/docker
or one of the other docker repos. Importing docker repos is a bit confusing with modules, including because:
- The
docker/docker
repo does not follow semver.
- There is a very old
v1.13.1
semver tag on the docker/docker
repo.
- Even though it is a couple years old, it is still the "latest" semver tag on that repo, and hence that old version is picked by default by the
go
command if you don't ask for a more specific version.
- That old
docker/docker
version imports the old and not incorrect uppercase Sirupsen/logrus
, which can then trigger the error reported in the question above.
- The docker client package has had breaking changes after v1.13.1.
- There is generally confusion about
docker/docker
vs. docker/engine
repositories, and about what import paths to use.
- The docker repos do not have
go.mod
files.
For the docker/docker
repo, the import path remains github.com/docker/docker
, but it needs to come from github.com/docker/engine
, so the recommended approach is often for a docker importer to do import "github.com/docker/docker"
and edit their go.mod
to something like this:
require (
github.com/docker/docker v1.13.1
)
replace github.com/docker/docker => github.com/docker/engine <tag-or-commit-hash>
Docker issue #39302 tracks trying to document how to import docker repos when using modules.
go mod why
? Although if you can't parsego.mod
, I'm not sure what you can do other than remove the offending module path. (also make sure you're using the latest go release to generatego.mod
, and rungo mod tidy
) – RivySirupsen
path in your code. – Rivy