From ad6fd61f94f8fdf6926f5dee6e45bdd13add2f9f Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Wed, 8 Mar 2023 19:46:19 -0500 Subject: [PATCH] zip: fix on Windows Zip paths are slash-delimited, so using filepath with them is incorrect. Change-Id: I5ad1ee90dea97427b9b291b6fbc52e5bdaf0b678 Reviewed-on: https://go-review.googlesource.com/c/mod/+/474815 TryBot-Result: Gopher Robot Run-TryBot: Heschi Kreinick Auto-Submit: Heschi Kreinick Reviewed-by: Bryan Mills --- zip/zip.go | 2 +- zip/zip_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zip/zip.go b/zip/zip.go index c5eca4b..7b48a2a 100644 --- a/zip/zip.go +++ b/zip/zip.go @@ -663,7 +663,7 @@ func filesInGitRepo(dir, rev, subdir string) ([]File, error) { if n == "" { continue } - n = strings.TrimPrefix(n, string(filepath.Separator)) + n = strings.TrimPrefix(n, "/") fs = append(fs, zipFile{ name: n, diff --git a/zip/zip_test.go b/zip/zip_test.go index 84a3ecd..173cc65 100644 --- a/zip/zip_test.go +++ b/zip/zip_test.go @@ -1532,7 +1532,7 @@ c/`))) } wantMap := map[string]bool{} for _, f := range tc.wantFiles { - p := filepath.Join("example.com", "foo", "bar@v0.0.1", f) + p := path.Join("example.com", "foo", "bar@v0.0.1", f) wantMap[p] = true }