builderpool

package module
v0.0.0-...-0ff03b3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: MIT Imports: 2 Imported by: 1

README

builderpool

Test Go Reference

A simple strings.Builder pool using sync.Pool inspired by lestrrat-go/bufferpool.

SYNOPSIS

import "github.com/nasa9084/go-builderpool"

var pool = builderpool.New()

func main() {
    builder := pool.Get()
    defer pool.Release(builder)

    // ...
}

Documentation

Overview

Package builderpool is a small wrapper of sync.Pool which is specified one to strings.Builder. Go 1.10 or later is required to use this package because the strings.Buidler is introduced with Go 1.10.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() *strings.Builder

Get returns a strings.Builder from the global pool.

func Release

func Release(builder *strings.Builder)

Release puts the given strings.Builder back into the global pool.

Types

type BuilderPool

type BuilderPool struct {
	// contains filtered or unexported fields
}

BuilderPool is wrapper struct of sync.Pool for strings.Builder objects.

func New

func New() *BuilderPool

New returns a new BuilderPool instance.

func (*BuilderPool) Get

func (bp *BuilderPool) Get() *strings.Builder

Get returns a strings.Builder from the pool.

func (*BuilderPool) Release

func (bp *BuilderPool) Release(builder *strings.Builder)

Release puts the given strings.Builder back into the pool after resetting the builder.

Jump to

Keyboard shortcuts

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