Bufio中的一些疑问

derek718 · · 835 次点击
这些问题在标准库的文档里面都可以找到答案: `type Reader ` `If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more.` `Callers should always process the n > 0 bytes returned before considering the error err. Doing so correctly handles I/O errors that happen after reading some bytes and also both of the allowed EOF behaviors.` 如果想把buf读满再返回,可以用io.ReadFull(), 返回nil表示读满了 `func ReadFull(r Reader, buf []byte) (n int, err error)`
#1