From 06395725d3107022979ec7848ad111ed3c654160 Mon Sep 17 00:00:00 2001 From: Fedor Korotkiy Date: Sat, 22 Feb 2020 01:54:46 +0300 Subject: [PATCH] Fix RandomName helper --- tools/testtool/bincache.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/testtool/bincache.go b/tools/testtool/bincache.go index aa60c01..5a792d7 100644 --- a/tools/testtool/bincache.go +++ b/tools/testtool/bincache.go @@ -55,7 +55,7 @@ func (c *localBinCache) GetBinary(importPath string) (string, error) { return v.(string), nil } - binPath := filepath.Join(c.dir, RandomName()) + binPath := filepath.Join(c.dir, RandomBinaryName()) if buildTags == "" { runGo("build", "-mod", "readonly", "-o", binPath, importPath) } else { @@ -105,12 +105,17 @@ func (c *ciBuildCache) GetBinary(importPath string) (string, error) { return binary, nil } -func RandomName() string { - var raw [8]byte - _, _ = rand.Read(raw[:]) - name := hex.EncodeToString(raw[:]) +func RandomBinaryName() string { + name := RandomName() if runtime.GOOS == "windows" { name += ".exe" } return name } + +func RandomName() string { + var raw [8]byte + _, _ = rand.Read(raw[:]) + name := hex.EncodeToString(raw[:]) + return name +}