init: v1.0.0

This commit is contained in:
yaole
2026-05-27 23:03:00 +08:00
commit 8d97f750eb
466 changed files with 80067 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
package grand
import (
"io"
)
// MustRead tries to fill p with len(p) bytes from r. If it haven't read enough bytes, then an
// error returns. So if nil error returns, then p must have read len(p) bytes. Otherwise, only
// p[:n] are read from r.
func MustRead(r io.Reader, p []byte) (int, error) {
n := 0
for len(p) > 0 {
m, err := r.Read(p)
if err != nil {
return n + m, err
}
p = p[m:]
n += m
}
return n, nil
}