amanar icon indicating copy to clipboard operation
amanar copied to clipboard

Potential import collision: import path should be "mvdan.cc/sh", not "github.com/mvdan/sh"

Open KateGo520 opened this issue 5 years ago • 1 comments

Background

I find that mvdan.cc/sh and github.com/mvdan/sh coexist in this repo: https://github.com/garetht/amanar/blob/master/go.mod (Line 14 & 25)

github.com/mvdan/sh v2.6.4+incompatible
mvdan.cc/sh v2.6.4+incompatible // indirect

That’s because the mvdan/sh has already renamed it’s import path from "github.com/mvdan/sh" to "mvdan.cc/sh". When you used the old path "github.com/mvdan/sh" to import mvdan/sh, go will reintroduces mvdan/sh through the import statements "import mvdan.cc/sh/…" in the go source file of mvdan/sh.

https://github.com/mvdan/sh/blob/v2.6.4/expand/braces.go#L6

package expand
import "mvdan.cc/sh/syntax"

The "mvdan.cc/sh" and "github.com/mvdan/sh" are the same repos. This will work in isolation, bring about potential risks and problems.

Solution

Follow the requirements of mvdan/sh doc:

package syntax
> import "mvdan.cc/sh/syntax"

Package syntax implements parsing and formatting of shell programs. It supports POSIX Shell, Bash, and mksh.
…

Replace all the old import paths, change "github.com/mvdan/sh" to "mvdan.cc/sh ". Where did you import it: https://github.com/garetht/amanar/search?q=github.com%2Fmvdan%2Fsh&unscoped_q=github.com%2Fmvdan%2Fsh

KateGo520 avatar Aug 10 '20 14:08 KateGo520

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

KateGo520 avatar Aug 10 '20 14:08 KateGo520