Documentation ¶
Index ¶
- Variables
- type Encoder
- func (Encoder) AppendArrayDelim(dst []byte) []byte
- func (Encoder) AppendArrayEnd(dst []byte) []byte
- func (Encoder) AppendArrayStart(dst []byte) []byte
- func (Encoder) AppendBeginMarker(dst []byte) []byte
- func (Encoder) AppendBool(dst []byte, val bool) []byte
- func (Encoder) AppendBools(dst []byte, vals []bool) []byte
- func (Encoder) AppendBytes(dst, s []byte) []byte
- func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte
- func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte
- func (Encoder) AppendEndMarker(dst []byte) []byte
- func (Encoder) AppendFloat32(dst []byte, val float32) []byte
- func (Encoder) AppendFloat64(dst []byte, val float64) []byte
- func (Encoder) AppendFloats32(dst []byte, vals []float32) []byte
- func (Encoder) AppendFloats64(dst []byte, vals []float64) []byte
- func (Encoder) AppendHex(dst, s []byte) []byte
- func (e Encoder) AppendIPAddr(dst []byte, ip net.IP) []byte
- func (e Encoder) AppendIPPrefix(dst []byte, pfx net.IPNet) []byte
- func (Encoder) AppendInt(dst []byte, val int) []byte
- func (Encoder) AppendInt16(dst []byte, val int16) []byte
- func (Encoder) AppendInt32(dst []byte, val int32) []byte
- func (Encoder) AppendInt64(dst []byte, val int64) []byte
- func (Encoder) AppendInt8(dst []byte, val int8) []byte
- func (e Encoder) AppendInterface(dst []byte, i interface{}) []byte
- func (Encoder) AppendInts(dst []byte, vals []int) []byte
- func (Encoder) AppendInts16(dst []byte, vals []int16) []byte
- func (Encoder) AppendInts32(dst []byte, vals []int32) []byte
- func (Encoder) AppendInts64(dst []byte, vals []int64) []byte
- func (Encoder) AppendInts8(dst []byte, vals []int8) []byte
- func (e Encoder) AppendKey(dst []byte, key string) []byte
- func (Encoder) AppendLineBreak(dst []byte) []byte
- func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte
- func (Encoder) AppendNil(dst []byte) []byte
- func (Encoder) AppendObjectData(dst []byte, o []byte) []byte
- func (Encoder) AppendString(dst []byte, s string) []byte
- func (e Encoder) AppendStrings(dst []byte, vals []string) []byte
- func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte
- func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte
- func (Encoder) AppendUint(dst []byte, val uint) []byte
- func (Encoder) AppendUint16(dst []byte, val uint16) []byte
- func (Encoder) AppendUint32(dst []byte, val uint32) []byte
- func (Encoder) AppendUint64(dst []byte, val uint64) []byte
- func (Encoder) AppendUint8(dst []byte, val uint8) []byte
- func (Encoder) AppendUints(dst []byte, vals []uint) []byte
- func (Encoder) AppendUints16(dst []byte, vals []uint16) []byte
- func (Encoder) AppendUints32(dst []byte, vals []uint32) []byte
- func (Encoder) AppendUints64(dst []byte, vals []uint64) []byte
- func (Encoder) AppendUints8(dst []byte, vals []uint8) []byte
Constants ¶
This section is empty.
Variables ¶
var JSONMarshalFunc func(v interface{}) ([]byte, error)
JSONMarshalFunc is used to marshal interface to JSON encoded byte slice. Making it package level instead of embedded in Encoder brings some extra efforts at importing, but avoids value copy when the functions of Encoder being invoked. DO REMEMBER to set this variable at importing, or you might get a nil pointer dereference panic at runtime.
Functions ¶
This section is empty.
Types ¶
type Encoder ¶ added in v1.7.0
type Encoder struct{}
func (Encoder) AppendArrayDelim ¶ added in v1.7.0
AppendArrayDelim adds markers to indicate end of a particular array element.
func (Encoder) AppendArrayEnd ¶ added in v1.7.0
AppendArrayEnd adds markers to indicate the end of an array.
func (Encoder) AppendArrayStart ¶ added in v1.7.0
AppendArrayStart adds markers to indicate the start of an array.
func (Encoder) AppendBeginMarker ¶ added in v1.7.0
AppendBeginMarker inserts a map start into the dst byte array.
func (Encoder) AppendBool ¶ added in v1.7.0
AppendBool converts the input bool to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendBools ¶ added in v1.7.0
AppendBools encodes the input bools to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendBytes ¶ added in v1.7.0
AppendBytes is a mirror of appendString with []byte arg
func (Encoder) AppendDuration ¶ added in v1.7.0
func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte
AppendDuration formats the input duration with the given unit & format and appends the encoded string to the input byte slice.
func (Encoder) AppendDurations ¶ added in v1.7.0
func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte
AppendDurations formats the input durations with the given unit & format and appends the encoded string list to the input byte slice.
func (Encoder) AppendEndMarker ¶ added in v1.7.0
AppendEndMarker inserts a map end into the dst byte array.
func (Encoder) AppendFloat32 ¶ added in v1.7.0
AppendFloat32 converts the input float32 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendFloat64 ¶ added in v1.7.0
AppendFloat64 converts the input float64 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendFloats32 ¶ added in v1.7.0
AppendFloats32 encodes the input float32s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendFloats64 ¶ added in v1.7.0
AppendFloats64 encodes the input float64s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendHex ¶ added in v1.7.0
AppendHex encodes the input bytes to a hex string and appends the encoded string to the input byte slice.
The operation loops though each byte and encodes it as hex using the hex lookup table.
func (Encoder) AppendIPAddr ¶ added in v1.7.0
AppendIPAddr adds IPv4 or IPv6 address to dst.
func (Encoder) AppendIPPrefix ¶ added in v1.7.0
AppendIPPrefix adds IPv4 or IPv6 Prefix (address & mask) to dst.
func (Encoder) AppendInt ¶ added in v1.7.0
AppendInt converts the input int to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendInt16 ¶ added in v1.7.0
AppendInt16 converts the input int16 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendInt32 ¶ added in v1.7.0
AppendInt32 converts the input int32 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendInt64 ¶ added in v1.7.0
AppendInt64 converts the input int64 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendInt8 ¶ added in v1.7.0
AppendInt8 converts the input []int8 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendInterface ¶ added in v1.7.0
AppendInterface marshals the input interface to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendInts ¶ added in v1.7.0
AppendInts encodes the input ints to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendInts16 ¶ added in v1.7.0
AppendInts16 encodes the input int16s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendInts32 ¶ added in v1.7.0
AppendInts32 encodes the input int32s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendInts64 ¶ added in v1.7.0
AppendInts64 encodes the input int64s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendInts8 ¶ added in v1.7.0
AppendInts8 encodes the input int8s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendLineBreak ¶ added in v1.7.0
AppendLineBreak appends a line break.
func (Encoder) AppendMACAddr ¶ added in v1.7.0
func (e Encoder) AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte
AppendMACAddr adds MAC address to dst.
func (Encoder) AppendNil ¶ added in v1.7.0
AppendNil inserts a 'Nil' object into the dst byte array.
func (Encoder) AppendObjectData ¶ added in v1.7.0
AppendObjectData takes in an object that is already in a byte array and adds it to the dst.
func (Encoder) AppendString ¶ added in v1.7.0
AppendString encodes the input string to json and appends the encoded string to the input byte slice.
The operation loops though each byte in the string looking for characters that need json or utf8 encoding. If the string does not need encoding, then the string is appended in it's entirety to the byte slice. If we encounter a byte that does need encoding, switch up the operation and perform a byte-by-byte read-encode-append.
func (Encoder) AppendStrings ¶ added in v1.7.0
AppendStrings encodes the input strings to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendTime ¶ added in v1.7.0
AppendTime formats the input time with the given format and appends the encoded string to the input byte slice.
func (Encoder) AppendTimes ¶ added in v1.7.0
AppendTimes converts the input times with the given format and appends the encoded string list to the input byte slice.
func (Encoder) AppendUint ¶ added in v1.7.0
AppendUint converts the input uint to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendUint16 ¶ added in v1.7.0
AppendUint16 converts the input uint16 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendUint32 ¶ added in v1.7.0
AppendUint32 converts the input uint32 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendUint64 ¶ added in v1.7.0
AppendUint64 converts the input uint64 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendUint8 ¶ added in v1.7.0
AppendUint8 converts the input uint8 to a string and appends the encoded string to the input byte slice.
func (Encoder) AppendUints ¶ added in v1.7.0
AppendUints encodes the input uints to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendUints16 ¶ added in v1.7.0
AppendUints16 encodes the input uint16s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendUints32 ¶ added in v1.7.0
AppendUints32 encodes the input uint32s to json and appends the encoded string list to the input byte slice.
func (Encoder) AppendUints64 ¶ added in v1.7.0
AppendUints64 encodes the input uint64s to json and appends the encoded string list to the input byte slice.