ghaoo / rboot

Rboot 是一个Go语言开发的一个简单、高效的 Chatops bot 框架
MIT License
68 stars 16 forks source link

Potential import collision: import path should be "gopkg.in/yaml.v2", not "github.com/go-yaml/yaml". #12

Closed KateGo520 closed 4 years ago

KateGo520 commented 4 years ago

Background

The go-yaml/yaml has already renamed it’s import path from "github.com/go-yaml/yaml" to "gopkg.in/yaml.v2". As README of go-yaml/yaml v2.1.0 said, downstream repos should use "gopkg.in/yaml.v2" to get or import go-yaml/yaml.

Example
Some more examples can be found in the "examples" folder.

package main
import (
        "fmt"
        "log"
        "gopkg.in/yaml.v2"
)
…

But ghaoo/rboot still used the old path: https://github.com/ghaoo/rboot/blob/master/go.mod#L11

github.com/go-yaml/yaml v2.1.0+incompatible 

When you use the old path "github.com/go-yaml/yaml" to import the go-yaml/yaml, it will be very easy to reintroduce go-yaml/yaml through the import statements "import gopkg.in/yaml.v2" in the go source file of go-yaml/yaml. https://github.com/go-yaml/yaml/blob/v2.1.0/decode_test.go#L12

package yaml_test
import (
    …
    . "gopkg.in/check.v1"
    "gopkg.in/yaml.v2"
)

The "gopkg.in/yaml.v2" and "github.com/go-yaml/yaml" are the same repos. This will work in isolation, bring about potential risks and problems. So, why not get rid of the old import path "github.com/go-yaml/yaml", use "gopkg.in/yaml.v2" instead.

Solution

Replace all the old import paths, change "github.com/go-yaml/yaml" to "gopkg.in/yaml.v2". Where did you import it: https://github.com/ghaoo/rboot/search?q=github.com%2Fgo-yaml%2Fyaml&unscoped_q=github.com%2Fgo-yaml%2Fyaml

KateGo520 commented 4 years ago

@ghaoo Could you help me review this issue? Thx :p

ghaoo commented 4 years ago

这两个其实属于一套代码,修改一下代码统一成一个就可以了

KateGo520 commented 4 years ago

Yes, just need to change the import path. Thank you for your reply. @ghaoo