stringbuilder

package module
v0.0.0-...-88dcb0d Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 16 Imported by: 0

README

stringbuilder

stringbuilder provides a convenient way to build strings.

Documentation

Overview

Package stringbuilder provides a convenient way to build strings.

Index

Constants

View Source
const (
	// Tdate the date in the local time zone: 2006-01-02
	Tdate = 1 << iota
	// Ttimeprefix add 'T' between date and time if set, otherwise add space.
	// Only with Ttime is valid
	Ttimeprefix
	// Ttime the time in the local time zone: 15:04:05
	Ttime
	// Tmilliseconds the time in the local time zone: 15:04:05.000
	Tmilliseconds
	// Tmicroseconds the time in the local time zone: 15:04:05.000000
	Tmicroseconds
	// Tnanoseconds the time in the local time zone: 15:04:05.000000000
	Tnanoseconds
	// TnineFlag use with Tmilliseconds or Tmicroseconds or Tnanoseconds.
	// If use this flag, 000... pattern switch to 999...
	TnineFlag
	// Tzone the local time zone: Z07:00
	Tzone
	// Tdatetime the date and time in the local time zone: 2006-01-02 15:04:05"
	Tdatetime = Tdate | Ttime
	// TdatetimeMilli the date and time(ms) in the local time zone: 2006-01-02 15:04:05.000"
	TdatetimeMilli = Tdate | Ttime | Tmilliseconds
	// TdatetimeMicro the date and time(ms) in the local time zone: 2006-01-02 15:04:05.000000"
	TdatetimeMicro = Tdate | Ttime | Tmicroseconds
	// TdatetimeNano the date and time(ms) in the local time zone: 2006-01-02 15:04:05.000000000"
	TdatetimeNano = Tdate | Ttime | Tnanoseconds
	// Trfc3339 is equivalent to time.RFC3339: 2006-01-02T15:04:05Z07:00
	Trfc3339 = Tdate | Ttimeprefix | Ttime | Tzone
	// Trfc3339Nano is equivalent to time.RFC3339Nano: 2006-01-02T15:04:05.999999999Z07:00
	Trfc3339Nano = Tdate | Ttimeprefix | Ttime | Tnanoseconds | TnineFlag | Tzone
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder []byte

Builder provides a convenient way to build strings using Write or Append methods. It's a redefinition of []byte It implements io.Writer and io.ByteWriter and io.StringWriter.

func (*Builder) AppendBool

func (b *Builder) AppendBool(v bool)

AppendBool appends "true" or "false", according to the value of v.

func (*Builder) AppendByteSlice

func (b *Builder) AppendByteSlice(v []byte)

AppendByteSlice appends a base64 string representing []byte v.

func (*Builder) AppendComplex128

func (b *Builder) AppendComplex128(val complex128)

AppendComplex128 appends the string form of the complex128 number f.

func (*Builder) AppendComplex64

func (b *Builder) AppendComplex64(val complex64)

AppendComplex64 appends the string form of the complex64 number f.

func (*Builder) AppendDuration

func (b *Builder) AppendDuration(d time.Duration)

AppendDuration appends the string form of the time.Duration.String().

func (*Builder) AppendFloat32

func (b *Builder) AppendFloat32(f float32)

AppendFloat32 appends the string form of the float32 number f.

func (*Builder) AppendFloat64

func (b *Builder) AppendFloat64(f float64)

AppendFloat64 appends the string form of the float64 number f.

func (*Builder) AppendHTMLQuote

func (b *Builder) AppendHTMLQuote(s string)

AppendHTMLQuote appends a double-quoted html string literal representing s.

func (*Builder) AppendInt

func (b *Builder) AppendInt(i int64)

AppendInt appends the string form of the int64 i.

func (*Builder) AppendJSON

func (b *Builder) AppendJSON(iv interface{}) (err error)

AppendJSON appends an json-style string literal representing v. It implements a json-encoded subset of encoding/json and remains compatible with encoding/json.

func (*Builder) AppendQuote

func (b *Builder) AppendQuote(s string)

AppendQuote appends a double-quoted Go string literal representing s.

func (*Builder) AppendTime

func (b *Builder) AppendTime(t time.Time, flag int)

AppendTime appends the textual representation in flag style to b. It has a faster formatting method that you can use if you are demanding performance, but it supports only a few formats

func (*Builder) AppendUint

func (b *Builder) AppendUint(i uint64)

AppendUint appends the string form of the uint64 i.

func (*Builder) AppendUintptr

func (b *Builder) AppendUintptr(p uintptr)

AppendUintptr appends the string form of the uintptr p.

func (*Builder) Bytes

func (b *Builder) Bytes() []byte

Bytes returns the builder's underlying byte slice.

func (*Builder) Cap

func (b *Builder) Cap() int

Cap returns the capacity of the builder's underlying byte slice. It is the total space allocated for the string being built and includes any bytes already written.

func (*Builder) Grow

func (b *Builder) Grow(n int)

Grow grows b's capacity, if necessary, to guarantee space for another n bytes. After Grow(n), at least n bytes can be written to b without another allocation. If n is negative, Grow panics.

func (*Builder) Len

func (b *Builder) Len() int

Len returns the number of accumulated bytes; b.Len() == len(b.String()).

func (*Builder) Reset

func (b *Builder) Reset()

Reset resets the Builder to be empty.

func (*Builder) String

func (b *Builder) String() string

String returns the accumulated string.

func (*Builder) Truncate

func (b *Builder) Truncate(n int)

Truncate discards all but the first n bytes from the b's buffer but continues to use the same allocated storage. It panics if n is negative or greater than b.Len().

func (*Builder) Write

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

Write implements io.Writer, appends the contents of p to b's buffer. Write always returns len(p), nil.

func (*Builder) WriteByte

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

WriteByte implements io.ByteWriter, appends the byte c to b's buffer. The returned error is always nil.

func (*Builder) WriteRune

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

WriteRune appends the UTF-8 encoding of Unicode code point r to b's buffer. It returns the length of r and a nil error.

func (*Builder) WriteString

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

WriteString implements io.StringWriter, appends the contents of s to b's buffer. It returns the length of s and a nil error.

Jump to

Keyboard shortcuts

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