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.

io.go 504B

12345678910111213141516171819
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package util
  4. import (
  5. "io"
  6. )
  7. // ReadAtMost reads at most len(buf) bytes from r into buf.
  8. // It returns the number of bytes copied. n is only less than len(buf) if r provides fewer bytes.
  9. // If EOF occurs while reading, err will be nil.
  10. func ReadAtMost(r io.Reader, buf []byte) (n int, err error) {
  11. n, err = io.ReadFull(r, buf)
  12. if err == io.EOF || err == io.ErrUnexpectedEOF {
  13. err = nil
  14. }
  15. return n, err
  16. }