add: notes to io ifaces
This commit is contained in:
@ -49,6 +49,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ioCopy streams from a file to another file.
|
||||||
|
// we use it to stream from the standard input to ouput.
|
||||||
func ioCopy(dst, src *os.File) error {
|
func ioCopy(dst, src *os.File) error {
|
||||||
// Use a fixed-length buffer to efficiently read from src stream in chunks.
|
// Use a fixed-length buffer to efficiently read from src stream in chunks.
|
||||||
buf := make([]byte, 32768)
|
buf := make([]byte, 32768)
|
||||||
@ -76,6 +78,7 @@ func ioCopy(dst, src *os.File) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// write method example.
|
||||||
func write(dst *os.File, buf []byte) error {
|
func write(dst *os.File, buf []byte) error {
|
||||||
nw, ew := dst.Write(buf)
|
nw, ew := dst.Write(buf)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user