From 35695913d5edd1e0df6f0f46bb44d3190c59c07b Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Mon, 25 Mar 2019 12:49:34 +0000 Subject: [PATCH 1/2] Allow for replace paths in modules.txt file --- main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index ee9d3f7..40920fa 100644 --- a/main.go +++ b/main.go @@ -67,11 +67,19 @@ func main() { line := scanner.Text() if line[0] == 35 { + // split input to use replace path if there is one + parts := strings.Split(line, "=>") + // remove leading spaces + line = strings.TrimLeft( + parts[len(parts)-1], + " ", + ) s := strings.Split(line, " ") + // use "relative" indexes, a replace line doesn't have a leading # value in its parts mod = &Mod{ - ImportPath: s[1], - Version: s[2], + ImportPath: s[len(s)-2], + Version: s[len(s)-1], } mod.Dir = pkgModPath(mod.ImportPath, mod.Version) From 93c1d99dc17bd188aa73a433fd2332c490375826 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Mon, 25 Mar 2019 14:30:49 +0000 Subject: [PATCH 2/2] Simplify fix to simply use a relative index, we only need the last 2 values of the line, regardless --- main.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/main.go b/main.go index 40920fa..f0b562a 100644 --- a/main.go +++ b/main.go @@ -67,13 +67,6 @@ func main() { line := scanner.Text() if line[0] == 35 { - // split input to use replace path if there is one - parts := strings.Split(line, "=>") - // remove leading spaces - line = strings.TrimLeft( - parts[len(parts)-1], - " ", - ) s := strings.Split(line, " ") // use "relative" indexes, a replace line doesn't have a leading # value in its parts