-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Got "ambiguous import: found github.com/ugorji/go/codec in multiple modules" after upgraded to latest (1.3.1) #1673
Comments
@mytharcher sorry, I can not reproduce the issue, my steps: |
Thanks for help @thinkerou ! I will have a try with the demo you provided. It looks really weird. |
At last, I found the answer which is another package depends on the ugorji/go/[email protected] explicitly. But seems for now go mod didn't solve the multi version dependency. |
looks like, thanks! |
I am having a similar problem. Here is my minimal test file ( package main
import (
"log"
"net/http"
"sync"
"github.com/gin-contrib/expvar"
"github.com/gin-gonic/gin"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
gin.SetMode(gin.ReleaseMode)
ginrouter := gin.New()
ginrouter.GET("/debug/vars", expvar.Handler())
svr := &http.Server{
Addr: ":8080",
Handler: ginrouter,
}
if err := svr.ListenAndServe(); err != nil {
log.Fatal("Could not listen")
}
}()
wg.Wait()
} There are three things I've tried so far. One: use go-mod and no go-getThis works fine: u@h:newproj$ pwd
/home/zannen/go/src/newproj
u@h:newproj$ rm -f go.{mod,sum}
u@h:newproj$ go mod init
go: creating new go.mod: module newproj
u@h:newproj$ go build -o main main.go
go: finding github.com/gin-contrib/expvar latest
u@h:newproj$ cat go.mod
module newproj
require github.com/gin-contrib/expvar v0.0.0-20181230111036-f23b556cc79f // indirect
u@h:newproj$ ./main &
[1] 23861
u@h:newproj$ curl localhost:8080/debug/vars
{ "cmdline": ["./main"], ... } Two: use go-get for gin then gin-contrib/expvarThis one fails, mentioning u@h:newproj$ pwd
/home/zannen/go/src/newproj
u@h:newproj$ rm -f go.{mod,sum}
u@h:newproj$ go mod init
go: creating new go.mod: module newproj
u@h:newproj$ go get github.com/gin-gonic/[email protected]
u@h:newproj$ go get github.com/gin-contrib/[email protected]
go build github.com/ugorji/go/codec: no Go files in
u@h:newproj$ # note weird error in the second go-get: gin-contrib/expvar
u@h:newproj$ cat go.mod
module newproj
require (
github.com/gin-contrib/expvar v0.0.0-20181230111036-f23b556cc79f // indirect
github.com/gin-gonic/gin v1.3.1-0.20190118015706-4867ff9634d1 // indirect
)
u@h:newproj$ go build -o main2 main2.go
../../pkg/mod/github.com/gin-gonic/[email protected]/binding/msgpack.go:12:2: unknown import path "github.com/ugorji/go/codec": ambiguous import: found github.com/ugorji/go/codec in multiple modules:
github.com/ugorji/go v1.1.1 (/home/zannen/go/pkg/mod/github.com/ugorji/[email protected]/codec)
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 (/home/zannen/go/pkg/mod/github.com/ugorji/go/[email protected])
Three: use go-get for gin-contrib/expvar then ginu@h:newproj$ pwd
/home/zannen/go/src/newproj
u@h:newproj$ rm -f go.{mod,sum}
u@h:newproj$ go mod init
go: creating new go.mod: module newproj
u@h:newproj$ go get github.com/gin-contrib/[email protected]
u@h:newproj$ go get github.com/gin-gonic/[email protected]
go build github.com/ugorji/go/codec: no Go files in
u@h:newproj$ # again, note weird error in the second go-get: gin-gonic/gin
u@h:newproj$ cat go.mod
module newproj
require (
github.com/gin-contrib/expvar v0.0.0-20181230111036-f23b556cc79f // indirect
github.com/gin-gonic/gin v1.3.1-0.20190118015706-4867ff9634d1 // indirect
)
u@h:newproj$ go build -o main main.go
../../pkg/mod/github.com/gin-gonic/[email protected]/binding/msgpack.go:12:2: unknown import path "github.com/ugorji/go/codec": ambiguous import: found github.com/ugorji/go/codec in multiple modules:
github.com/ugorji/go v1.1.1 (/home/zannen/go/pkg/mod/github.com/ugorji/[email protected]/codec)
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 (/home/zannen/go/pkg/mod/github.com/ugorji/go/[email protected]) ConclusionI'm still investigating, but I'll have to avoid using |
I just meet the same issue. Any solution? |
Nope. I just gave up converting to go modules, wasn't that important to me |
you need vpn |
I find a way to fix this problem, you can use
The full
|
@gsgtzq Thanks!! I solved the problem . |
the dependent repo has changed, please refer to : |
gin need update ugorji/go go-playground/validator.v8, wait 1.4.0 release . |
|
I tried then solutions above but they didn't work for me. I still get the error:
|
it occurs another problem when using unit test |
I had same issue, this instruction solved error. |
add this code to go.mod , it was worked
|
Hi folks, Please see ugorji/go#299 and add your thoughts/ideas/etc. Thanks. |
This fixed the issue for my repo (leaving off
|
If use
If use
so, I suggest to upgrade gin to |
@jrefior Thanks! |
FYI: I just released a go-codec production release - version 1.1.7 (finally) First, it resolves the go.mod impasse where we had different import paths (github.com/ugorji/go and github.com/ugorji/go/codec) causing the ambiguous import error. This is now fixed by leveraging import cycles to ensure that either one works well and resolves to the same bits. Please let me know if seeing any issues. If all is well over the next few days, I will close this github issue. |
@ugorji thanks a lot! |
@ugorji Is it possible to release ugorji/go v2, then gin can import it using semantic versioning, import (
ugorji "github.com/ugorji/go/v2"
) This enforces the use of new code while other projects can still use old versions. |
Thanks |
…version to avoid package conflict re: gin-gonic/gin#1673
With issues:
go version: 1.11
gin version (or commit ref): v1.3.1-0.20181126150151-b97ccf3a43d2
operating system: Mac/Ubuntu
Description
I found a new feature
ShouldBindUri
in README doc but no any releases contains it. So I install by go mod:Then the gin version has been updated to
v1.3.1-0.20181126150151-b97ccf3a43d2
ingo.mod
file.When I run
go build
I got this error output:But if I remove the folder
/go/pkg/mod/github.com/ugorji/[email protected]/codec
everything goes right.Not sure if this caused by the new version of gin or go mod.
Hope you could help!
Thanks.
The text was updated successfully, but these errors were encountered: