cmd/go/internal/modfetch: fix cache fails on Windows
Asterisks are not valid in a Windows path. Replace "*" with "-".
Fixes golang/go#25950
Change-Id: Ie6447a0f07cbe371b6807a8e6919547219b60560
Reviewed-on: https://go-review.googlesource.com/119615
Run-TryBot: Baokun Lee <nototon@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/vendor/cmd/go/internal/modfetch/cache.go b/vendor/cmd/go/internal/modfetch/cache.go
index cc7a34b..b7cf4a5 100644
--- a/vendor/cmd/go/internal/modfetch/cache.go
+++ b/vendor/cmd/go/internal/modfetch/cache.go
@@ -324,7 +324,7 @@
return err
}
// Write data to temp file next to target file.
- f, err := ioutil.TempFile(filepath.Dir(file), filepath.Base(file)+".tmp*")
+ f, err := ioutil.TempFile(filepath.Dir(file), filepath.Base(file)+".tmp-")
if err != nil {
return err
}
diff --git a/vendor/cmd/go/internal/modfetch/cache_test.go b/vendor/cmd/go/internal/modfetch/cache_test.go
new file mode 100644
index 0000000..87b1cdc
--- /dev/null
+++ b/vendor/cmd/go/internal/modfetch/cache_test.go
@@ -0,0 +1,25 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package modfetch
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func TestWriteDiskCache(t *testing.T) {
+ tmpdir, err := ioutil.TempDir("", "vgo-writeCache-test-")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tmpdir)
+
+ err = writeDiskCache(filepath.Join(tmpdir, "file"), []byte("data"))
+ if err != nil {
+ t.Fatal(err)
+ }
+}