Go standard library-io io/ioutil

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Interface Definition-BASIC interface

//-----------------------------------------------------------------------------//============================== ===== Basic Interface ===================================//----------------------------------------------------------------- The------------//Reader interface is used to output its own byte data. There is only one duck method read. Parameter P: reads the data stream of the object into P, and P is the []byte] that the caller prepares to hold the data. return value://1 If the data is read (n > 0) Err = nil//2 If no data is readable (n = 0) Then err = io. eof//3 If a read error occurs (n = _) Then Err = other Errorstype reader interface {Read (P []byte) (n int, err error)}//Writer interface for data Write to itself. Only one duck method is write. Parameter P: Writes the data in P to the object, and P is the data prepared by the caller.    return value://1 If the data is all written (n = len (P)), err = nil//2 If the data cannot be written all (n = number of bytes written), then err = other Errorstype Writer interface { Write (P []byte) (n int, err error)}//Closer interface is used to close the data read and write handle. Only one duck method is close. The type Closer interface {Close () error}//Seeker interface is used to move data read-write pointers. There is only one duck method to seek. Same as C language. Parameter whence://if whence is 0: Moves the pointer from the beginning of the data. If whence is 1: Moves the pointer starting at the current pointer position of the data. If whence is 2: Indicates that the pointer is moved from the end of the data. The parameter offset://is the offset of the pointer movement (theoretically it can be positive or negative, and of course some flowsis not supported. )。 return value://Returns the new pointer position and the error encountered. Type Seeker Interface {Seek (offset int64, whence int) (ret int64, err error)}//--------------------------------------- --------------------------------------//================================= Basic Combination Interface ================================ =//-----------------------------------------------------------------------------

 

Related Article

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.