From 68da2e5a227e23043455ceb3b26c5abaae168372 Mon Sep 17 00:00:00 2001 From: Zou Guangxian Date: Sun, 2 Aug 2020 14:33:27 +0800 Subject: [PATCH 1/3] support replace directive with local path in go.mod --- main.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 07a4932..a7036e9 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,7 @@ func main() { if line[0] == 35 { s := strings.Split(line, " ") - if (len(s) != 6 && len(s) != 3) || s[1] == "explicit" { + if (len(s) != 5 && len(s) != 6 && len(s) != 3) || s[1] == "explicit" { continue } @@ -90,9 +90,16 @@ func main() { } // Handle "replace" in module file if any if len(s) > 3 && s[3] == "=>" { - mod.SourcePath = s[4] - mod.SourceVersion = s[5] - mod.Dir = pkgModPath(mod.SourcePath, mod.SourceVersion) + switch(len(s)) { + case 5: + mod.SourcePath = s[4] + mod.SourceVersion = s[2] + mod.Dir = filepath.Join(cwd, s[4]) + case 6: + mod.SourcePath = s[4] + mod.SourceVersion = s[5] + mod.Dir = pkgModPath(mod.SourcePath, mod.SourceVersion) + } } else { mod.Dir = pkgModPath(mod.ImportPath, mod.Version) } From e01a8ff2be11c10e39658284d4ad8e3bead6ebf6 Mon Sep 17 00:00:00 2001 From: Zou Guangxian Date: Mon, 3 Aug 2020 15:07:25 +0800 Subject: [PATCH 2/3] fix module path. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d76e416..00d36af 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/goware/modvendor +module github.com/zouguangxian/modvendor require github.com/mattn/go-zglob v0.0.2-0.20191112051448-a8912a37f9e7 From 5c351944c50127c1f24ca71e4edbe90b7ab34044 Mon Sep 17 00:00:00 2001 From: Zou Guangxian Date: Sat, 12 Sep 2020 17:11:01 +0800 Subject: [PATCH 3/3] fix "module path does not exist, check $GOPATH/pkg/mod" --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index a7036e9..a046843 100644 --- a/main.go +++ b/main.go @@ -104,6 +104,17 @@ func main() { mod.Dir = pkgModPath(mod.ImportPath, mod.Version) } + ignore := true + for _, dir := range additionalDirsToInclude { + if strings.HasPrefix(dir, mod.ImportPath) { + ignore = false + } + } + + if ignore { + continue + } + if _, err := os.Stat(mod.Dir); os.IsNotExist(err) { fmt.Printf("Error! %q module path does not exist, check $GOPATH/pkg/mod\n", mod.Dir) os.Exit(1)