Golang io several points to keep in mind

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

The trouble with reader is to remember the following:

When Read encounters a error or End-of-file condition after successfully reading n > 0 bytes, it returns the number of Bytes read. It may return the Non-nil error from the same call or return the error (and n = = 0) from a subsequent call

For write, it's simple to remember:

Write writes Len (p) bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= len (p)) and any error encountered this caused the write to Stop early. Write must return a non-nil error if it returns n < Len (p). Write must not modify the slice data, even temporarily.

For Bytereader: is a byte-by-byte read

Buio is the upper-level package for IO, he handles some general error situations, and so on, while reading support reads until a byte is encountered, and so on, there are other common features.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.