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 ================================ =//-----------------------------------------------------------------------------