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
}
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
}