github.com/prysmaticlabs/prysm@v1.4.4/tools/analyzers/properpermissions/testdata/regular_imports.go (about) 1 package testdata 2 3 import ( 4 "crypto/rand" 5 "fmt" 6 "io/ioutil" 7 "math/big" 8 "os" 9 "path/filepath" 10 ) 11 12 func tempDir() string { 13 d := os.Getenv("TEST_TMPDIR") 14 if d == "" { 15 return os.TempDir() 16 } 17 return d 18 } 19 20 // UseOsMkdirAllAndWriteFile -- 21 func UseOsMkdirAllAndWriteFile() { 22 randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000)) 23 p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath)) 24 _ = os.MkdirAll(p, os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil" 25 someFile := filepath.Join(p, "some.txt") 26 _ = ioutil.WriteFile(someFile, []byte("hello"), os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil" 27 }