Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

read_full.go 397B

123456789101112131415161718192021
  1. package utils
  2. import "io"
  3. const readFullBufferSize = 1024 + 1 // +1 because telegram opreates with blocks mod 4
  4. func ReadFull(src io.Reader) (rv []byte, err error) {
  5. buf := make([]byte, readFullBufferSize)
  6. n := readFullBufferSize
  7. for n == len(buf) {
  8. n, err = src.Read(buf)
  9. if err != nil {
  10. return nil, err // nolint: wrapcheck
  11. }
  12. rv = append(rv, buf[:n]...)
  13. }
  14. return rv, nil
  15. }