Open jerome-laforge opened 5 years ago
For reference, the error message is:
build testmod: cannot load github.com/ugorji/go/codec: ambiguous import: found github.com/ugorji/go/codec in multiple modules:
github.com/ugorji/go v1.1.4 (/tmp/gopath660937702/pkg/mod/github.com/ugorji/go@v1.1.4/codec)
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 (/tmp/gopath660937702/pkg/mod/github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8)
The two modules don't require each other at versions that would avoid the ambiguous import.
It's hard to capture all this in an error message, but we might recommend requiring specific versions of these modules to avoid the ambiguous import.
Related #27899
It's hard to capture all this in an error message, but we might recommend requiring specific versions of these modules to avoid the ambiguous import.
I think if we can recommend an upgrade that resolves the ambiguous import, we should just apply it instead of telling the user to apply it.
the proposed solution, that works for me, is:
go get github.com/ugorji/go/codec@none
I note that this issue predates the resolution of https://github.com/ugorji/go/issues/299.
With that resolved, go get github.com/ugorji/go/codec@latest
should also resolve the problem with the module graph. (The versions in the example are still incompatible, but due to breaking API changes rather than an ambiguous import path: https://play.golang.org/p/YXT3Pc69yYM.)
For the errors in that playground link, I believe at least one set of the errors is due to fsnotify not supporting nacl/amd64p32.
That might explain all the errors there.
Change https://golang.org/cl/196298 mentions this issue: cmd/go/internal/modload: use a structured error for 'ambiguous import'
Any way to resolve -- ambiguous import: found package time in multiple modules: ??
What version of Go are you using (
go version
)?1.12
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?What did you do?
I deal with a problem of ambiguous module import when I try to import
github.com/spf13/viper@1.3.2
andgithub.com/gin-gonic/gin@v1.4.0
https://play.golang.org/p/NwzVwWsOjbO
What did you expect to see?
@thepudds (thx to him for his support) has advised me to open a issue to have clearer diagnostic message or a simpler solution.
the proposed solution, that works for me, is:
go get github.com/ugorji/go/codec@none
https://groups.google.com/forum/#!topic/golang-nuts/0mJh8SkaomA