Initial import
This commit is contained in:
parent
258b52017a
commit
c6ed1a115b
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var buf [1048576]byte
|
||||
|
||||
fd, err := os.Open("/dev/urandom")
|
||||
if err != nil {
|
||||
log.Fatal("Couldn't open urandom, " + err.Error())
|
||||
}
|
||||
count, err := io.ReadFull(fd, buf[:])
|
||||
if err != nil || count != len(buf) {
|
||||
log.Fatal("COuldn't read bytes, " + err.Error())
|
||||
}
|
||||
fd.Close()
|
||||
i := 0
|
||||
total := 0
|
||||
fd, err = os.Create("tmp.dat")
|
||||
for {
|
||||
i, err = fd.Write(buf[:])
|
||||
if err != nil || i != 1048576 {
|
||||
fmt.Printf("EOF at %dmb, %s\n", total, err.Error())
|
||||
fd.Close()
|
||||
os.Remove("tmp.dat")
|
||||
log.Fatal("End")
|
||||
}
|
||||
total++
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue