mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-11 20:20:05 +00:00
386b69f473
* fix incorrect exported name in comments * add comments to exported methods
28 lines
735 B
Go
28 lines
735 B
Go
package testdata
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"math/big"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func tempDir() string {
|
|
d := os.Getenv("TEST_TMPDIR")
|
|
if d == "" {
|
|
return os.TempDir()
|
|
}
|
|
return d
|
|
}
|
|
|
|
// UseOsMkdirAllAndWriteFile --
|
|
func UseOsMkdirAllAndWriteFile() {
|
|
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
|
|
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
|
|
_ = os.MkdirAll(p, os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
|
|
someFile := filepath.Join(p, "some.txt")
|
|
_ = ioutil.WriteFile(someFile, []byte("hello"), os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
|
|
}
|