Fix RandomName helper
This commit is contained in:
parent
b066362940
commit
06395725d3
1 changed files with 10 additions and 5 deletions
|
@ -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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue