bufpool

package module
v0.0.0-...-37fed97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2017 License: MIT Imports: 2 Imported by: 1

README

Package bufpool

bufpool provides a thin wrapper around sync.Pool that is used to store *bytes.Buffer.

Usage


// Create a new pool
p := bufpool.New()

// Get bytes.Buffer from pool
buf := p.Get()

buf.WriteString("Hello, World!")
fmt.Println(buf.String())

// Put the buffer back into the pool
p.Put(buf)

I've implemented this enough times that this small dependency comes in handy in reducing boilerplate code.

Documentation

Overview

Package bufpool is a thin wrapper around sync.Pool that stores *bytes.Buffer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	sync.Pool
}

func New

func New() *Pool

func (*Pool) Get

func (p *Pool) Get() *bytes.Buffer

func (*Pool) Put

func (p *Pool) Put(b *bytes.Buffer)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL