bufpool

package module
v0.0.0-...-deb29da Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: BSD-3-Clause Imports: 2 Imported by: 3

README

Buffer Pool

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() *bytes.Buffer

Get returns a Buffer from the pool

func Put

func Put(buf *bytes.Buffer)

Put returns a buffer from the pool

func PutAndCopy

func PutAndCopy(buf *bytes.Buffer) []byte

PutAndCopy returns the buffer to the pool and returns a copy of it's byte slice

func PutStr

func PutStr(buf *bytes.Buffer) string

PutStr returns a buffer from the pool and returns it's value as a string

Types

type BufferPool

type BufferPool interface {
	Get() *bytes.Buffer
	Put(buf *bytes.Buffer)
}

BufferPool can Get or Put a Buffer to a pool

var Pool BufferPool = &bufferPool{
	pool: &sync.Pool{
		New: func() interface{} {
			return &bytes.Buffer{}
		},
	},
}

Pool is the package instance of BufferPool.

Jump to

Keyboard shortcuts

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