Fix RandomName helper

This commit is contained in:
Fedor Korotkiy 2020-02-22 01:54:46 +03:00
parent b066362940
commit 06395725d3

View file

@ -55,7 +55,7 @@ func (c *localBinCache) GetBinary(importPath string) (string, error) {
return v.(string), nil return v.(string), nil
} }
binPath := filepath.Join(c.dir, RandomName()) binPath := filepath.Join(c.dir, RandomBinaryName())
if buildTags == "" { if buildTags == "" {
runGo("build", "-mod", "readonly", "-o", binPath, importPath) runGo("build", "-mod", "readonly", "-o", binPath, importPath)
} else { } else {
@ -105,12 +105,17 @@ func (c *ciBuildCache) GetBinary(importPath string) (string, error) {
return binary, nil return binary, nil
} }
func RandomName() string { func RandomBinaryName() string {
var raw [8]byte name := RandomName()
_, _ = rand.Read(raw[:])
name := hex.EncodeToString(raw[:])
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
name += ".exe" name += ".exe"
} }
return name return name
} }
func RandomName() string {
var raw [8]byte
_, _ = rand.Read(raw[:])
name := hex.EncodeToString(raw[:])
return name
}