strbld

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

strbld package provides a string Builder that can be used with older go versions as well. The builder provided by strings.Builder will be used for go versions 1.10+. The Builder interface is fully compatible to strings.Builder. Only additional methods available are Pad and Fmt. If go versions < 1.10 are used, no additional methods of the underlying buffer can be used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder provides support to construct a string using Write methods. It minimizes memory copying.

func (*Builder) Fmt

func (b *Builder) Fmt(s string, vs ...interface{})

Fmt writes the formatted string to the buffer.

func (*Builder) Grow

func (b *Builder) Grow(n int)

Grow increases the buffer its capacity if required. After grow, at least n bytes can be written without further allocations.

func (*Builder) Len

func (b *Builder) Len() int

Len returns the number of bytes written to the buffer.

func (*Builder) Pad

func (b *Builder) Pad(str string)

Pad writes str to the buffer, only if the buffer is not empty.

func (*Builder) Reset

func (b *Builder) Reset()

Reset clears the buffer. The buffer for a new string will not be shared with the original strings buffer.

func (*Builder) String

func (b *Builder) String() string

String returns the buffered contents as string.

func (*Builder) Write

func (b *Builder) Write(p []byte) (int, error)

Write appends p to the buffer. Write always returns len(p), nil.

func (*Builder) WriteByte

func (b *Builder) WriteByte(c byte) error

WriteByte appends c to the buffer. WriteByte always returns nil.

func (*Builder) WriteRune

func (b *Builder) WriteRune(r rune) (int, error)

WriteRune appends r to the buffer. WriteRune always returns the length or r (UTF-8 encoded) and nil.

func (*Builder) WriteString

func (b *Builder) WriteString(s string) (int, error)

WriteString appends s to the buffer. WriteString always returns len(s), nil.

Jump to

Keyboard shortcuts

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