Potential import collision: import path should be "gopkg.in/gorethink/gorethink.v4", not "github.com/dancannon/gorethink"
Closed this issue · 5 comments
Background
I find that gopkg.in/gorethink/gorethink.v4
and github.com/dancannon/gorethink
coexist in this repo:
https://github.com/adrian83/chat/blob/master/go.mod (Line 5 & 16)
github.com/dancannon/gorethink v4.0.0+incompatible
gopkg.in/gorethink/gorethink.v4 v4.1.0 // indirect
That’s because the gorethink
has already renamed it’s import path from "github.com/dancannon/gorethink" to "gopkg.in/gorethink/gorethink.v4",in the version v4.x.y . When you use the old path "github.com/dancannon/gorethink" to import the gorethink
, will reintroduces gorethink
through the import statements "import gopkg.in/gorethink/gorethink.v4" in the go source file of gorethink
.
https://github.com/rethinkdb/rethinkdb-go/blob/v4.0.0/query_db.go#L4
package gorethink
import (
p "gopkg.in/gorethink/gorethink.v4/ql2"
)
"gopkg.in/gorethink/gorethink.v4" and "github.com/dancannon/gorethink" are the same repos. This will work in isolation, bring about potential risks and problems.
Solution
Follow the requirements of rethinkdb/rethinkdb-go README.md:
**Installation**
go get gopkg.in/gorethink/gorethink.v4
Replace v4 with v3 or v2 to use previous versions.
**Example**
package gorethink_test
import (
"fmt"
"log"
r "gopkg.in/gorethink/gorethink.v4"
)…
Replace all the old import paths, change "github.com/dancannon/gorethink"
to "gopkg.in/gorethink/gorethink.v4"
.
If you want to get version v5
, use import path "gopkg.in/rethinkdb/rethinkdb-go.v5"
.
If you want to get version v6
, use import path "gopkg.in/rethinkdb/rethinkdb-go.v6"
.
Where did you import it: https://github.com/adrian83/chat/search?q=github.com%2Fdancannon%2Fgorethink&unscoped_q=github.com%2Fdancannon%2Fgorethink
@KateGo520 Thanks for letting me know. I will try to fix it in a few hours when I have some free time.
@KateGo520 Should be ok now.
Best regards
Thank you for your contribution! @adrian83
It looks like the same problem here. https://github.com/adrian83/chat/blob/master/go.mod(Line 13 & 23)
github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect
gotest.tools v2.2.0+incompatible // indirect
"github.com/gotestyourself/gotestyourself" and "gotest.tools" are the same repos.
You can solve the problem through this way:
Add replace statement in the go.mod file:
replace github.com/gotestyourself/gotestyourself => gotest.tools v2.2.0
Then clean the go.mod.
Hi @KateGo520
Both of these dependencies were removed from my go.mod