"os"
"path/filepath"
"strconv"
+ "sync"
"time"
)
// chance the file doesn't exist yet - keeps the number of tries in
// TempFile to a minimum.
var rand uint32
+var randmu sync.Mutex
func reseed() uint32 {
return uint32(time.Now().UnixNano() + int64(os.Getpid()))
}
func nextSuffix() string {
+ randmu.Lock()
r := rand
if r == 0 {
r = reseed()
}
r = r*1664525 + 1013904223 // constants from Numerical Recipes
rand = r
+ randmu.Unlock()
return strconv.Itoa(int(1e9 + r%1e9))[1:]
}