Documentation ¶
Index ¶
- Variables
- func AppendHTMLEscape(dst []byte, s string) []byte
- func AppendHTMLEscapeBytes(dst, s []byte) []byte
- func AppendHTTPDate(dst []byte, date time.Time) []byte
- func AppendIPv4(dst []byte, ip net.IP) []byte
- func AppendQuotedArg(dst, src []byte) []byte
- func AppendUint(dst []byte, n int) []byte
- func ParseHTTPDate(date []byte) (time.Time, error)
- func ParseIPv4(dst net.IP, ipStr []byte) (net.IP, error)
- func ParseUfloat(buf []byte) (float64, error)
- func ParseUint(buf []byte) (int, error)
- func ReleaseArgs(a *Args)
- func ReleaseByteBuffer(b *ByteBuffer)
- type Args
- func (a *Args) Add(key, value string)
- func (a *Args) AddBytesK(key []byte, value string)
- func (a *Args) AddBytesKV(key, value []byte)
- func (a *Args) AddBytesV(key string, value []byte)
- func (a *Args) AppendBytes(dst []byte) []byte
- func (a *Args) CopyTo(dst *Args)
- func (a *Args) Del(key string)
- func (a *Args) DelBytes(key []byte)
- func (a *Args) GetBool(key string) bool
- func (a *Args) GetUfloat(key string) (float64, error)
- func (a *Args) GetUfloatOrZero(key string) float64
- func (a *Args) GetUint(key string) (int, error)
- func (a *Args) GetUintOrZero(key string) int
- func (a *Args) Has(key string) bool
- func (a *Args) HasBytes(key []byte) bool
- func (a *Args) Len() int
- func (a *Args) Parse(s string)
- func (a *Args) ParseBytes(b []byte)
- func (a *Args) Peek(key string) []byte
- func (a *Args) PeekBytes(key []byte) []byte
- func (a *Args) PeekMulti(key string) [][]byte
- func (a *Args) PeekMultiBytes(key []byte) [][]byte
- func (a *Args) QueryString() []byte
- func (a *Args) Reset()
- func (a *Args) Set(key, value string)
- func (a *Args) SetBytesK(key []byte, value string)
- func (a *Args) SetBytesKV(key, value []byte)
- func (a *Args) SetBytesV(key string, value []byte)
- func (a *Args) SetUint(key string, value int)
- func (a *Args) SetUintBytes(key []byte, value int)
- func (a *Args) String() string
- func (a *Args) VisitAll(f func(key, value []byte))
- func (a *Args) WriteTo(w io.Writer) (int64, error)
- type BufferPool
- type BufioReader
- func (b *BufioReader) Buffered() int
- func (b *BufioReader) Count() int64
- func (b *BufioReader) Discard(n int) (discarded int, err error)
- func (b *BufioReader) Read(p []byte) (int, error)
- func (b *BufioReader) ReadByte() (byte, error)
- func (b *BufioReader) Reset(r io.Reader)
- func (b *BufioReader) ResetCount()
- func (b *BufioReader) ResetLimit(limit int64)
- type BufioWriter
- func (b *BufioWriter) Available() int
- func (b *BufioWriter) Buffered() int
- func (b *BufioWriter) Count() int64
- func (b *BufioWriter) Flush() error
- func (b *BufioWriter) ReadFrom(r io.Reader) (int64, error)
- func (b *BufioWriter) Reset(w io.Writer)
- func (b *BufioWriter) ResetCount()
- func (b *BufioWriter) Write(p []byte) (int, error)
- func (b *BufioWriter) WriteByte(c byte) error
- func (b *BufioWriter) WriteRune(r rune) (int, error)
- func (b *BufioWriter) WriteString(s string) (int, error)
- type ByteBuffer
- func (b *ByteBuffer) Bytes() []byte
- func (b *ByteBuffer) ChangeLen(newLen int)
- func (b *ByteBuffer) Len() int
- func (b *ByteBuffer) Read(p []byte) (int, error)
- func (b *ByteBuffer) ReadFrom(r io.Reader) (int64, error)
- func (b *ByteBuffer) Reset()
- func (b *ByteBuffer) Set(p []byte)
- func (b *ByteBuffer) SetString(s string)
- func (b *ByteBuffer) String() string
- func (b *ByteBuffer) Write(p []byte) (int, error)
- func (b *ByteBuffer) WriteByte(c byte) error
- func (b *ByteBuffer) WriteString(s string) (int, error)
- func (b *ByteBuffer) WriteTo(w io.Writer) (int64, error)
- type ReaderWrap
- type WriterWrap
Constants ¶
This section is empty.
Variables ¶
var ErrNoArgValue = errors.New("no Args value for the given key")
ErrNoArgValue is returned when Args value with the given key is missing.
Functions ¶
func AppendHTMLEscape ¶
AppendHTMLEscape appends html-escaped s to dst and returns the extended dst.
func AppendHTMLEscapeBytes ¶
AppendHTMLEscapeBytes appends html-escaped s to dst and returns the extended dst.
func AppendHTTPDate ¶
AppendHTTPDate appends HTTP-compliant (RFC1123) representation of date to dst and returns the extended dst.
func AppendIPv4 ¶
AppendIPv4 appends string representation of the given ip v4 to dst and returns the extended dst.
func AppendQuotedArg ¶
AppendQuotedArg appends url-encoded src to dst and returns appended dst.
func AppendUint ¶
AppendUint appends n to dst and returns the extended dst.
func ParseHTTPDate ¶
ParseHTTPDate parses HTTP-compliant (RFC1123) date.
func ParseUfloat ¶
ParseUfloat parses unsigned float from buf.
func ReleaseArgs ¶
func ReleaseArgs(a *Args)
ReleaseArgs returns the object acquired via AquireArgs to the pool.
Do not access the released Args object, otherwise data races may occur.
func ReleaseByteBuffer ¶
func ReleaseByteBuffer(b *ByteBuffer)
ReleaseByteBuffer returns byte buffer to the pool.
ByteBuffer.B mustn't be touched after returning it to the pool. Otherwise data races will occur.
Types ¶
type Args ¶
type Args struct {
// contains filtered or unexported fields
}
Args represents query arguments.
It is forbidden copying Args instances. Create new instances instead and use CopyTo().
Args instance MUST NOT be used from concurrently running goroutines.
func AcquireArgs ¶
func AcquireArgs() *Args
AcquireArgs returns an empty Args object from the pool.
The returned Args may be returned to the pool with ReleaseArgs when no longer needed. This allows reducing GC load.
func (*Args) AddBytesK ¶
AddBytesK adds 'key=value' argument.
Multiple values for the same key may be added.
func (*Args) AddBytesKV ¶
AddBytesKV adds 'key=value' argument.
Multiple values for the same key may be added.
func (*Args) AddBytesV ¶
AddBytesV adds 'key=value' argument.
Multiple values for the same key may be added.
func (*Args) AppendBytes ¶
AppendBytes appends query string to dst and returns the extended dst.
func (*Args) GetBool ¶
GetBool returns boolean value for the given key.
true is returned for '1', 'y' and 'yes' values, otherwise false is returned.
func (*Args) GetUfloatOrZero ¶
GetUfloatOrZero returns ufloat value for the given key.
Zero (0) is returned on error.
func (*Args) GetUintOrZero ¶
GetUintOrZero returns uint value for the given key.
Zero (0) is returned on error.
func (*Args) ParseBytes ¶
ParseBytes parses the given b containing query args.
func (*Args) Peek ¶
Peek returns query arg value for the given key.
Returned value is valid until the next Args call.
func (*Args) PeekBytes ¶
PeekBytes returns query arg value for the given key.
Returned value is valid until the next Args call.
func (*Args) PeekMultiBytes ¶
PeekMultiBytes returns all the arg values for the given key.
func (*Args) QueryString ¶
QueryString returns query string for the args.
The returned value is valid until the next call to Args methods.
func (*Args) SetBytesKV ¶
SetBytesKV sets 'key=value' argument.
func (*Args) SetUintBytes ¶
SetUintBytes sets uint value for the given key.
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool represents byte buffer pool.
Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.
func (*BufferPool) Get ¶
func (p *BufferPool) Get() *ByteBuffer
Get returns new byte buffer with zero length.
The byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead.
func (*BufferPool) Put ¶
func (p *BufferPool) Put(b *ByteBuffer)
Put releases byte buffer obtained via Get to the pool.
The buffer mustn't be accessed after returning to the pool.
type BufioReader ¶
type BufioReader struct {
// contains filtered or unexported fields
}
BufioReader an io.Reader object buffer with count and limit.
func NewBufioReader ¶
func NewBufioReader(r io.Reader, limit ...int64) *BufioReader
NewBufioReader returns a new BufioReader whose buffer has the default size.
func NewBufioReaderSize ¶
func NewBufioReaderSize(r io.Reader, size int, limit ...int64) *BufioReader
NewBufioReaderSize returns a new BufioReader whose buffer has at least the specified size. If the argument io.Reader is already a BufioReader with large enough size, it returns the underlying BufioReader.
func (*BufioReader) Buffered ¶
func (b *BufioReader) Buffered() int
Buffered returns the number of bytes that can be read from the current buffer.
func (*BufioReader) Discard ¶
func (b *BufioReader) Discard(n int) (discarded int, err error)
Discard skips the next n bytes, returning the number of bytes discarded.
If Discard skips fewer than n bytes, it also returns an error. If 0 <= n <= b.Buffered(), Discard is guaranteed to succeed without reading from the underlying io.Reader.
func (*BufioReader) Read ¶
func (b *BufioReader) Read(p []byte) (int, error)
Read reads data into p. It returns the number of bytes read into p. The bytes are taken from at most one Read on the underlying Reader, hence n may be less than len(p). At EOF, the count will be zero and err will be io.EOF.
func (*BufioReader) ReadByte ¶
func (b *BufioReader) ReadByte() (byte, error)
ReadByte reads and returns a single byte. If no byte is available, returns an error.
func (*BufioReader) Reset ¶
func (b *BufioReader) Reset(r io.Reader)
Reset discards any buffered data, resets all state, switches the buffered reader to read from r, resets count, and resets limit.
func (*BufioReader) ResetLimit ¶
func (b *BufioReader) ResetLimit(limit int64)
ResetLimit resets the limit.
type BufioWriter ¶
type BufioWriter struct {
// contains filtered or unexported fields
}
BufioWriter implements buffering for an io.Writer object with count. If an error occurs writing to a BufioWriter, no more data will be accepted and all subsequent writes, and Flush, will return the error. After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer.
func NewBufioWriter ¶
func NewBufioWriter(w io.Writer) *BufioWriter
NewBufioWriter returns a new BufioWriter whose buffer has the default size.
func NewBufioWriterSize ¶
func NewBufioWriterSize(w io.Writer, size int) *BufioWriter
NewBufioWriterSize returns a new BufioWriter whose buffer has at least the specified size. If the argument io.Writer is already a BufioWriter with large enough size, it returns the underlying BufioWriter.
func (*BufioWriter) Available ¶
func (b *BufioWriter) Available() int
Available returns how many bytes are unused in the buffer.
func (*BufioWriter) Buffered ¶
func (b *BufioWriter) Buffered() int
Buffered returns the number of bytes that have been written into the current buffer.
func (*BufioWriter) Flush ¶
func (b *BufioWriter) Flush() error
Flush writes any buffered data to the underlying io.Writer.
func (*BufioWriter) ReadFrom ¶
func (b *BufioWriter) ReadFrom(r io.Reader) (int64, error)
ReadFrom implements io.ReaderFrom.
func (*BufioWriter) Reset ¶
func (b *BufioWriter) Reset(w io.Writer)
Reset discards any unflushed buffered data, clears any error, resets b to write its output to w, and resets count.
func (*BufioWriter) Write ¶
func (b *BufioWriter) Write(p []byte) (int, error)
Write writes the contents of p into the buffer. It returns the number of bytes written. If nn < len(p), it also returns an error explaining why the write is short.
func (*BufioWriter) WriteByte ¶
func (b *BufioWriter) WriteByte(c byte) error
WriteByte writes a single byte.
func (*BufioWriter) WriteRune ¶
func (b *BufioWriter) WriteRune(r rune) (int, error)
WriteRune writes a single Unicode code point, returning the number of bytes written and any error.
func (*BufioWriter) WriteString ¶
func (b *BufioWriter) WriteString(s string) (int, error)
WriteString writes a string. It returns the number of bytes written. If the count is less than len(s), it also returns an error explaining why the write is short.
type ByteBuffer ¶
type ByteBuffer struct { // B is a byte buffer to use in append-like workloads. // See example code for details. B []byte }
ByteBuffer provides byte buffer, which can be used for minimizing memory allocations.
ByteBuffer may be used with functions appending data to the given []byte slice. See example code for details.
Use Get for obtaining an empty byte buffer.
func AcquireByteBuffer ¶
func AcquireByteBuffer() *ByteBuffer
AcquireByteBuffer returns an empty byte buffer from the pool.
Got byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.
func (*ByteBuffer) Bytes ¶
func (b *ByteBuffer) Bytes() []byte
Bytes returns b.B, i.e. all the bytes accumulated in the buffer.
The purpose of this function is bytes.Buffer compatibility.
func (*ByteBuffer) ChangeLen ¶
func (b *ByteBuffer) ChangeLen(newLen int)
ChangeLen changes the buffer length.
func (*ByteBuffer) Read ¶
func (b *ByteBuffer) Read(p []byte) (int, error)
Read implements io.Reader.
func (*ByteBuffer) ReadFrom ¶
func (b *ByteBuffer) ReadFrom(r io.Reader) (int64, error)
ReadFrom implements io.ReaderFrom.
The function appends all the data read from r to b.
func (*ByteBuffer) SetString ¶
func (b *ByteBuffer) SetString(s string)
SetString sets ByteBuffer.B to s.
func (*ByteBuffer) String ¶
func (b *ByteBuffer) String() string
String returns string representation of ByteBuffer.B.
func (*ByteBuffer) Write ¶
func (b *ByteBuffer) Write(p []byte) (int, error)
Write implements io.Writer - it appends p to ByteBuffer.B
func (*ByteBuffer) WriteByte ¶
func (b *ByteBuffer) WriteByte(c byte) error
WriteByte appends the byte c to the buffer.
The purpose of this function is bytes.Buffer compatibility.
The function always returns nil.
func (*ByteBuffer) WriteString ¶
func (b *ByteBuffer) WriteString(s string) (int, error)
WriteString appends s to ByteBuffer.B.
type ReaderWrap ¶
type ReaderWrap struct {
// contains filtered or unexported fields
}
ReaderWrap reader wrapper
type WriterWrap ¶
type WriterWrap struct {
// contains filtered or unexported fields
}
WriterWrap writer wrapper