io.Writer interface
The inverse of io.Reader is io.Writer interface:
type Writer interface { Write(p []byte) (n int, err error) } Compared to io.Reader, since you no need to consider io.EOF error, the process of Write method is simple:
(1) err == nil: All the data in p is written successfully;
(2) err != nil: The data in p is partially or not written at all.
Let’s see an example:
package main import ( "log" "os" ) func main() { f, err := os.
[Read More]