Skip to content

A fork of Go's standard bufio package, adding support for buffer injected writers.

License

Notifications You must be signed in to change notification settings

ahmedabdou14/bufio

Repository files navigation

bufio fork: writer buffer injection

godoc - documentation go report card github action - test codecov - code coverage

A fork of Go's standard bufio package, adding support for buffer injected writers.

Installation

go get -u github.com/ahmedabdou14/bufio

Usage

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() 
}

Why?

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

Warning ⚠️

Be carful of using the buffer after passing it to the writer. Doings so will result in unexpected behavior.

About

A fork of Go's standard bufio package, adding support for buffer injected writers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages