From 5ac7f7d75f4b07576dd74a74bdf2310d3e680e00 Mon Sep 17 00:00:00 2001 From: itchyny Date: Fri, 8 Jan 2021 19:32:22 +0900 Subject: [PATCH] use strconv.FormatUint with base 16 to generate temporary paths --- mmv.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mmv.go b/mmv.go index 3e5eaf1..4b6fae9 100644 --- a/mmv.go +++ b/mmv.go @@ -1,10 +1,10 @@ package mmv import ( - "fmt" "math/rand" "os" "path/filepath" + "strconv" "strings" ) @@ -251,7 +251,7 @@ func buildRenames(files map[string]string) ([]rename, error) { // create a temporary path where there is no file currently func temporaryPath(dir string) (string, error) { for i := 0; i < 256; i++ { - path := filepath.Join(dir, fmt.Sprint(rand.Uint64())) + path := filepath.Join(dir, strconv.FormatUint(rand.Uint64()|1<<60, 16)) if _, err := os.Stat(path); err != nil && os.IsNotExist(err) { return path, nil }