bufio.Bufio 代码阅读

2022-04-18  本文已影响0人  wayyyy

bufio 实现了有缓冲的I/O,它包装了一个io.Reader 或 io.Writer 接口对象

bufio.png
缓冲区状态
Reader 对象
type Reader struct {
    buf          []byte
    rd           io.Reader // reader provided by the client
    r, w         int       // buf read and write positions
    err          error
    lastByte     int // last byte read for UnreadByte; -1 means invalid
    lastRuneSize int // size of last rune read for UnreadRune; -1 means invalid
}
Writer 对象
上一篇 下一篇

猜你喜欢

热点阅读