Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: ambiguous error message on ambiguous import #32128

Open
jerome-laforge opened this issue May 18, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@jerome-laforge
Copy link

commented May 18, 2019

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)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build116507160=/tmp/go-build -gno-record-gcc-switches"

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 and github.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

@ALTree ALTree changed the title [modules] Ambiguous message for ambiguous import cmd/go: ambiguous error message on ambiguous import May 18, 2019

@ALTree ALTree added this to the Go1.14 milestone May 18, 2019

@jayconrod

This comment has been minimized.

Copy link
Contributor

commented May 30, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.