A fork of Go's standard bufio package, adding support for buffer injected writers.
go get -u github.com/ahmedabdou14/bufio
package main
import (
"os"
"github.com/ahmedabdou14/bufio"
)
func main() {
file, err := os.Create("test.txt")
if err != nil {
panic(err)
}
defer file.Close()
buf := make([]byte, 10)
w := bufio.NewWriterBuffer(file, buf)
w.WriteString("Hello, World!")
w.Flush()
}
Only use this package if you need the fine-grained control over the buffers used by the writer. One use case is when you want to reuse buffers for multiple writers and somewhere else in your code. For more details, checkout this issue
Maybe you do not need this package, in most usecases, you would only need to reuse the writers themselves, not the buffers. For more details, checkout this issue
Be carful of using the buffer after passing it to the writer. Doings so will result in unexpected behavior.