Closed aler9 closed 1 year ago
Hello, rand.Read() is based on io.ReadFull, which already returns an error when n != len(p):
rand.Read()
io.ReadFull
n != len(p)
https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/crypto/rand/rand.go;l=24
https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/io/io.go;l=351
Furthermore, this is also written into the documentation:
Read is a helper function that calls Reader.Read using io.ReadFull. On return, n == len(b) if and only if err == nil.
Therefore, checking n != len(p) after rand.Read() is useless.
Hello,
rand.Read()
is based onio.ReadFull
, which already returns an error whenn != len(p)
:https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/crypto/rand/rand.go;l=24
https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/io/io.go;l=351
Furthermore, this is also written into the documentation:
Therefore, checking
n != len(p)
afterrand.Read()
is useless.