diff --git a/cmd/main.go b/cmd/main.go index 0a3b2f4..c9bc76e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -292,8 +292,6 @@ func parseGoListJson(out []byte) (currentModule, moduleDir string, replacements continue } - src := mod.Path + "@" + mod.Version - // 1. Target is module, version is required in this case // 2A. Target is absolute path // 2B. Target is relative path, proper handling is required in this case @@ -315,7 +313,7 @@ func parseGoListJson(out []byte) (currentModule, moduleDir string, replacements } } - replacements = append(replacements, xcaddy.NewReplace(src, dst)) + replacements = append(replacements, xcaddy.NewReplace(mod.Path, dst)) } for _, idx := range unjoinedReplaces { unresolved := string(replacements[idx].New) diff --git a/cmd/main_unix_test.go b/cmd/main_unix_test.go index e226425..a340623 100644 --- a/cmd/main_unix_test.go +++ b/cmd/main_unix_test.go @@ -95,12 +95,12 @@ func TestParseGoListJson(t *testing.T) { t.Errorf("Unexpected module path") } expected := []xcaddy.Replace{ - xcaddy.NewReplace("replacetest1@v1.2.3", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"), - xcaddy.NewReplace("replacetest2@v0.0.1", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"), - xcaddy.NewReplace("replacetest3@v1.2.3", "/home/work/module/fork1"), + xcaddy.NewReplace("replacetest1", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"), + xcaddy.NewReplace("replacetest2", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"), + xcaddy.NewReplace("replacetest3", "/home/work/module/fork1"), xcaddy.NewReplace("github.com/simnalamburt/module", "/home/work/module"), - xcaddy.NewReplace("replacetest4@v0.0.1", "/srv/fork2"), - xcaddy.NewReplace("replacetest5@v1.2.3", "/home/work/module/fork3"), + xcaddy.NewReplace("replacetest4", "/srv/fork2"), + xcaddy.NewReplace("replacetest5", "/home/work/module/fork3"), } if !reflect.DeepEqual(replacements, expected) { t.Errorf("Expected replacements '%v' but got '%v'", expected, replacements) diff --git a/cmd/main_windows_test.go b/cmd/main_windows_test.go index 3d65e58..173ff84 100644 --- a/cmd/main_windows_test.go +++ b/cmd/main_windows_test.go @@ -99,12 +99,12 @@ func TestParseGoListJson(t *testing.T) { t.Errorf("Unexpected module path") } expected := []xcaddy.Replace{ - xcaddy.NewReplace("replacetest1@v1.2.3", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"), - xcaddy.NewReplace("replacetest2@v0.0.1", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"), - xcaddy.NewReplace("replacetest3@v1.2.3", "C:\\Users\\work\\module\\fork1"), + xcaddy.NewReplace("replacetest1", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"), + xcaddy.NewReplace("replacetest2", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"), + xcaddy.NewReplace("replacetest3", "C:\\Users\\work\\module\\fork1"), xcaddy.NewReplace("github.com/simnalamburt/module", "C:\\Users\\work\\module"), - xcaddy.NewReplace("replacetest4@v0.0.1", "C:\\go\\fork2"), - xcaddy.NewReplace("replacetest5@v1.2.3", "C:\\Users\\work\\module\\fork3"), + xcaddy.NewReplace("replacetest4", "C:\\go\\fork2"), + xcaddy.NewReplace("replacetest5", "C:\\Users\\work\\module\\fork3"), } if !reflect.DeepEqual(replacements, expected) { t.Errorf("Expected replacements '%v' but got '%v'", expected, replacements)