Documentation ¶
Overview ¶
Package stringbuilder provides a convenient way to build strings.
Index ¶
- Constants
- type Builder
- func (b *Builder) AppendBool(v bool)
- func (b *Builder) AppendByteSlice(v []byte)
- func (b *Builder) AppendComplex128(val complex128)
- func (b *Builder) AppendComplex64(val complex64)
- func (b *Builder) AppendDuration(d time.Duration)
- func (b *Builder) AppendFloat32(f float32)
- func (b *Builder) AppendFloat64(f float64)
- func (b *Builder) AppendHTMLQuote(s string)
- func (b *Builder) AppendInt(i int64)
- func (b *Builder) AppendJSON(iv interface{}) (err error)
- func (b *Builder) AppendQuote(s string)
- func (b *Builder) AppendTime(t time.Time, flag int)
- func (b *Builder) AppendUint(i uint64)
- func (b *Builder) AppendUintptr(p uintptr)
- func (b *Builder) Bytes() []byte
- func (b *Builder) Cap() int
- func (b *Builder) Grow(n int)
- func (b *Builder) Len() int
- func (b *Builder) Reset()
- func (b *Builder) String() string
- func (b *Builder) Truncate(n int)
- func (b *Builder) Write(p []byte) (int, error)
- func (b *Builder) WriteByte(c byte) error
- func (b *Builder) WriteRune(r rune) (int, error)
- func (b *Builder) WriteString(s string) (int, error)
Constants ¶
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 ¶
AppendBool appends "true" or "false", according to the value of v.
func (*Builder) AppendByteSlice ¶
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 ¶
AppendComplex64 appends the string form of the complex64 number f.
func (*Builder) AppendDuration ¶
AppendDuration appends the string form of the time.Duration.String().
func (*Builder) AppendFloat32 ¶
AppendFloat32 appends the string form of the float32 number f.
func (*Builder) AppendFloat64 ¶
AppendFloat64 appends the string form of the float64 number f.
func (*Builder) AppendHTMLQuote ¶
AppendHTMLQuote appends a double-quoted html string literal representing s.
func (*Builder) AppendJSON ¶
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 ¶
AppendQuote appends a double-quoted Go string literal representing s.
func (*Builder) AppendTime ¶
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 ¶
AppendUint appends the string form of the uint64 i.
func (*Builder) AppendUintptr ¶
AppendUintptr appends the string form of the uintptr p.
func (*Builder) Cap ¶
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 ¶
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) Truncate ¶
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 ¶
Write implements io.Writer, appends the contents of p to b's buffer. Write always returns len(p), nil.
func (*Builder) WriteByte ¶
WriteByte implements io.ByteWriter, appends the byte c to b's buffer. The returned error is always nil.