Create a file generating function
Closed this issue · 3 comments
alicjakwie commented
We want to use a pseudo-random byte generator using math/rand in go to generate file contents
evanSpendlove commented
Include generating the file name here (as per Cian's comment):
Example function signature:
func GiveMeAFile(int id, int64 size) (string, io.LimitedReader)
With LimitedReader supplying the file contents.
evanSpendlove commented
Working on this now.
evanSpendlove commented
For the mutex locking we can use something similar to the private read() method in math/rand:
We will need to implement a locked source ourselves first.
// read implements Read for a lockedSource without a race condition.
func (r *lockedSource) read(p []byte, readVal *int64, readPos *int8) (n int, err error) {
r.lk.Lock()
n, err = read(p, r.src, readVal, readPos)
r.lk.Unlock()
return
}