Documentation
¶
Index ¶
- Variables
- func KeyInMap(m map[string]interface{}, k string) bool
- func LoadJSONFile2Obj(fileName string, v interface{}) error
- func MapVal2Bool(m map[string]interface{}, k string) bool
- func MapVal2Bytes(m map[string]interface{}, k string) []byte
- func MapVal2Duration(m map[string]interface{}, k string) (time.Duration, bool)
- func MapVal2Float64(m map[string]interface{}, k string) float64
- func MapVal2Int(m map[string]interface{}, k string) int
- func MapVal2Int32(m map[string]interface{}, k string) int32
- func MapVal2Int64(m map[string]interface{}, k string) int64
- func MapVal2String(m map[string]interface{}, k string) string
- func MapVal2StringList(m map[string]interface{}, k string) []string
- func MapVal2Time(m map[string]interface{}, k string) (time.Time, bool)
- func ToBool(v interface{}) bool
- func ToBytes(v interface{}) []byte
- func ToDuration(v interface{}) (time.Duration, bool)
- func ToFloat64(v interface{}) float64
- func ToInt(v interface{}) int
- func ToInt32(v interface{}) int32
- func ToInt64(v interface{}) int64
- func ToString(v interface{}) string
- func ToStringList(v interface{}) []string
- func ToTime(v interface{}) (time.Time, bool)
- func ToUInt(v interface{}) uint
- func ToUInt32(v interface{}) uint32
- func ToUInt64(v interface{}) uint64
- type Base64Bytes
- type BufferX
- func (b *BufferX) Bytes() []byte
- func (b *BufferX) Len() int
- func (b *BufferX) ReWrite(pos int, p []byte)
- func (b *BufferX) ReWriteU32(pos int, v uint32)
- func (b *BufferX) Read(p []byte) error
- func (b *BufferX) ReadBool() (bool, error)
- func (b *BufferX) ReadF64() (float64, error)
- func (b *BufferX) ReadI16() (int16, error)
- func (b *BufferX) ReadI32() (int32, error)
- func (b *BufferX) ReadI64() (int64, error)
- func (b *BufferX) ReadLimitString(limit uint32) (string, error)
- func (b *BufferX) ReadN(n int) ([]byte, error)
- func (b *BufferX) ReadString() (string, error)
- func (b *BufferX) ReadU8() (byte, error)
- func (b *BufferX) ReadU16() (uint16, error)
- func (b *BufferX) ReadU32() (uint32, error)
- func (b *BufferX) ReadU64() (uint64, error)
- func (b *BufferX) ReadVarI32() (int32, error)
- func (b *BufferX) ReadVarI64() (int64, error)
- func (b *BufferX) ReadVarU32() (uint32, error)
- func (b *BufferX) ReadVarU64() (uint64, error)
- func (b *BufferX) Reset()
- func (b *BufferX) Write(p []byte)
- func (b *BufferX) WriteBool(v bool)
- func (b *BufferX) WriteF64(v float64)
- func (b *BufferX) WriteI16(v int16)
- func (b *BufferX) WriteI32(v int32)
- func (b *BufferX) WriteI64(v int64)
- func (b *BufferX) WriteLimitString(limit uint32, val string) error
- func (b *BufferX) WriteString(val string)
- func (b *BufferX) WriteU8(v byte)
- func (b *BufferX) WriteU16(v uint16)
- func (b *BufferX) WriteU32(v uint32)
- func (b *BufferX) WriteU64(v uint64)
- func (b *BufferX) WriteVarI32(v int32)
- func (b *BufferX) WriteVarI64(v int64)
- func (b *BufferX) WriteVarU32(v uint32)
- func (b *BufferX) WriteVarU64(v uint64)
- func (b *BufferX) ZReadN(n int) ([]byte, error)
- type CompressType
- type IBufferX
- type IReaderX
- type JsByte
- type JsDuration
- type JsInt64
- type JsUInt64
- type ReaderX
- func (b *ReaderX) Read(p []byte) error
- func (b *ReaderX) ReadBool() (bool, error)
- func (b *ReaderX) ReadByte() (byte, error)
- func (b *ReaderX) ReadF64() (float64, error)
- func (b *ReaderX) ReadI16() (int16, error)
- func (b *ReaderX) ReadI32() (int32, error)
- func (b *ReaderX) ReadI64() (int64, error)
- func (b *ReaderX) ReadLimitString(limit uint32) (string, error)
- func (b *ReaderX) ReadN(n int) ([]byte, error)
- func (b *ReaderX) ReadString() (string, error)
- func (b *ReaderX) ReadU16() (uint16, error)
- func (b *ReaderX) ReadU32() (uint32, error)
- func (b *ReaderX) ReadU64() (uint64, error)
- func (b *ReaderX) ZReadN(n int) ([]byte, error)
- type U64BitMap
- func (b U64BitMap) Bytes() []byte
- func (b *U64BitMap) FromBytes(buf []byte)
- func (b U64BitMap) Full() bool
- func (b U64BitMap) Left() []byte
- func (b U64BitMap) LeftX(plus byte) []byte
- func (b U64BitMap) Len() int
- func (b U64BitMap) ReverseLen() int
- func (b *U64BitMap) Set(i byte)
- func (b U64BitMap) Values() []byte
- func (b U64BitMap) ValuesX(plus byte) []byte
- type U128BitMap
- type Unix2Time
- type UnixNano2Time
- type UnixStamp
Constants ¶
This section is empty.
Variables ¶
var ( ErrByteBufferEmpty = errors.New("byte.buffer.empty") ErrReadWrongNum = errors.New("byte.buffer.wrong.num") ErrSizeLimit = errors.New("byte.buffer.size.limit") )
var ( JSONMarshal = jsonStd.Marshal JSONUnmarshal = jsonStd.Unmarshal )
标准jsoniter json库 100%兼容
var ( JSONFastMarshal = jsonFast.Marshal JSONFastUnmarshal = jsonFast.Unmarshal JSONFastMarshalSnappy = fastMarshalSnappy JSONFastUnmarshalSnappy = fastUnmarshalSnappy TrySnappyCompress = compressJSON )
快速jsoniter json库 -- 浮点数会丢失精度,小数点最多后6位
var (
ErrInvalidByteJs = errors.New(`byte.invalid.string`)
)
var (
ErrInvalidDurationJs = errors.New(`duration invalid string`)
)
var (
ErrInvalidInt64Js = errors.New(`int64 invalid string`)
)
var (
ErrInvalidUInt64Js = errors.New(`uint64 invalid string`)
)
var (
Snappy = &_Snappy{}
)
Functions ¶
func LoadJSONFile2Obj ¶
LoadJSONFile2Obj 读取json文件并序列化到传入的指针中
func MapVal2Bool ¶
MapVal2Bool : 将map中的value转换为bool
func MapVal2Bytes ¶
MapVal2Bytes : 将map中的value转换为[]byte
func MapVal2Duration ¶ added in v0.0.3
MapVal2Duration : 将map中的value转换为Duration
func MapVal2Float64 ¶
MapVal2Float64 : 将map中的value转换为float64
func MapVal2Int ¶
MapVal2Int : 将map中的value转换为int
func MapVal2Int32 ¶
MapVal2Int32 : 将map中的value转换为int32
func MapVal2Int64 ¶
MapVal2Int64 : 将map中的value转换为int64
func MapVal2String ¶
MapVal2String : 将map中的value转换为string
func MapVal2StringList ¶
MapVal2StringList : 将map中的value转换为string list
func MapVal2Time ¶
MapVal2Time : 将map中的value转换为time
func ToDuration ¶ added in v0.0.3
ToDuration 转换为time.Duration
Types ¶
type Base64Bytes ¶
type Base64Bytes []byte
func (*Base64Bytes) Scan ¶
func (i *Base64Bytes) Scan(value interface{}) error
type BufferX ¶
type BufferX struct {
// contains filtered or unexported fields
}
BufferX buffer implement
func NewReadableBuffer ¶ added in v0.2.3
NewReadableBuffer new buffer from existed bytes to read. Use existed bytes to fill buffer, the buffer is always used as read stream.
func NewSizedBuffer ¶ added in v0.2.3
NewSizedBuffer : new buffer with specific size
func (*BufferX) ReWriteU32 ¶
ReWriteU32 rewrite uint32
func (*BufferX) ReadLimitString ¶
ReadLimitString read limit size string
func (*BufferX) ReadVarI32 ¶ added in v0.1.6
ReadVarI32 read variant int32
func (*BufferX) ReadVarI64 ¶ added in v0.1.6
ReadVarI64 read variant int64
func (*BufferX) ReadVarU32 ¶ added in v0.1.6
ReadVarU32 read variant uint32
func (*BufferX) ReadVarU64 ¶ added in v0.1.6
ReadVarU64 read variant uint64
func (*BufferX) WriteLimitString ¶
WriteLimitString write limit size string
func (*BufferX) WriteVarI32 ¶ added in v0.1.6
WriteVarI32 write variant int32
func (*BufferX) WriteVarI64 ¶ added in v0.1.6
WriteVarI64 write variant int64
func (*BufferX) WriteVarU32 ¶ added in v0.1.6
WriteVarU32 write variant uint32
func (*BufferX) WriteVarU64 ¶ added in v0.1.6
WriteVarU64 write variant uint64
type CompressType ¶
type CompressType byte
const ( CompressThreshHold = 256 CompressSnappy CompressType = 128 )
type IBufferX ¶
type IBufferX interface {
//Len : length
Len() int
//Read specific p, if length is not enough, return error
Read(p []byte) error
//ReadN n bytes, if length is not enough, return error
ReadN(n int) ([]byte, error)
//Write to buffer
Write(p []byte)
//Bytes left bytes
Bytes() []byte
//Reset reset cursor
Reset()
//ReWrite a buffer
ReWrite(pos int, p []byte)
//ReWriteU32 rewrite with a specific pos
ReWriteU32(pos int, v uint32)
//ReadU8 read byte
ReadU8() (byte, error)
//WriteU8 write byte
WriteU8(byte)
//ReadBool read bool
ReadBool() (bool, error)
//WriteBool write bool
WriteBool(bool)
//ReadLimitString read string
ReadLimitString(limit uint32) (string, error)
//WriteLimitString write string
WriteLimitString(limit uint32, val string) error
//ReadString read string
ReadString() (string, error)
//WriteString write string
WriteString(val string)
//ReadU16 read uint16
ReadU16() (uint16, error)
//WriteU16 write uint16
WriteU16(uint16)
//ReadI16 read int16
ReadI16() (int16, error)
//WriteI16 write int16
WriteI16(int16)
//ReadU32 read uint32
ReadU32() (uint32, error)
//WriteU32 write uint32
WriteU32(uint32)
//ReadI32 read int32
ReadI32() (int32, error)
//WriteI32 write int32
WriteI32(int32)
//ReadU64 read uint64
ReadU64() (uint64, error)
//WriteU64 write uint64
WriteU64(uint64)
//ReadI64 read int64
ReadI64() (int64, error)
//WriteI64 write int64
WriteI64(int64)
//ReadF64 read float64
ReadF64() (float64, error)
//WriteF64 write float64
WriteF64(float64)
}
IBufferX buffer interface
type IReaderX ¶
type IReaderX interface {
//Read : read specific p, if length is not enough, return error
Read(p []byte) error
//ReadN : read n bytes, if length is not enough, return error
ReadN(n int) ([]byte, error)
ZReadN(n int) ([]byte, error)
//ReadByte : read byte
ReadByte() (byte, error)
//ReadBool : read bool
ReadBool() (bool, error)
//ReadLimitString : read string
ReadLimitString(limit uint32) (string, error)
//ReadString : read string
ReadString() (string, error)
//ReadU16 : read uint16
ReadU16() (uint16, error)
//ReadI16 : read int16
ReadI16() (int16, error)
//ReadU32 : read uint32
ReadU32() (uint32, error)
//ReadI32 : read int32
ReadI32() (int32, error)
//ReadU64 : read uint64
ReadU64() (uint64, error)
//ReadI64 : read int64
ReadI64() (int64, error)
//ReadF64 : read float64
ReadF64() (float64, error)
}
IReaderX reader interface
type JsByte ¶
type JsByte []byte
JsByte json could not support readable []byte use string to replace the byte array
func (*JsByte) UnmarshalJSON ¶
UnmarshalJSON unmarshal json
type JsDuration ¶ added in v0.0.3
func NewJsDuration ¶ added in v0.0.3
func NewJsDuration(d time.Duration) JsDuration
func (*JsDuration) From ¶ added in v0.0.3
func (i *JsDuration) From(d time.Duration)
From : from duration
func (JsDuration) MarshalJSON ¶ added in v0.0.3
func (i JsDuration) MarshalJSON() ([]byte, error)
MarshalJSON marshal json
func (*JsDuration) UnmarshalJSON ¶ added in v0.0.3
func (i *JsDuration) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshal json
func (*JsDuration) UnmarshalTOML ¶ added in v0.0.3
func (i *JsDuration) UnmarshalTOML(v interface{}) error
UnmarshalTOML unmarshal toml
type JsInt64 ¶
type JsInt64 int64
JsInt64 json could not support large number use string to replace the number if a field is int64
func MapVal2JsInt64 ¶
MapVal2JsInt64 : 将map中的value转换为 json int64
func (JsInt64) MarshalJSON ¶
MarshalJSON marshal json
func (*JsInt64) UnmarshalJSON ¶
UnmarshalJSON unmarshal json
type JsUInt64 ¶
type JsUInt64 uint64
JsUInt64 json could not support large number use string to replace the number if a field is uint64
func ToJsUInt64 ¶ added in v0.0.3
func ToJsUInt64(v interface{}) JsUInt64
ToJsUInt64 将基本类型转换为json uint64整型
func (JsUInt64) MarshalJSON ¶
MarshalJSON marshal json
func (*JsUInt64) UnmarshalJSON ¶
UnmarshalJSON unmarshal json
type ReaderX ¶
type ReaderX struct {
// contains filtered or unexported fields
}
ReaderX buffer implement
func (*ReaderX) ReadLimitString ¶
ReadLimitString read limit size string
type U128BitMap ¶
U128BitMap use 2 uint64 Low and High
func (*U128BitMap) Bytes ¶
func (u *U128BitMap) Bytes() []byte
func (*U128BitMap) FromBytes ¶
func (u *U128BitMap) FromBytes(buf []byte)
func (*U128BitMap) Full ¶
func (u *U128BitMap) Full() bool
func (*U128BitMap) Left ¶
func (u *U128BitMap) Left() []byte
func (*U128BitMap) Len ¶
func (u *U128BitMap) Len() int
func (*U128BitMap) ReverseLen ¶
func (u *U128BitMap) ReverseLen() int
func (*U128BitMap) Set ¶
func (u *U128BitMap) Set(i byte)
func (*U128BitMap) Values ¶
func (u *U128BitMap) Values() []byte
type UnixNano2Time ¶
UnixNano2Time 纳秒时间戳时间
type UnixStamp ¶
type UnixStamp int64
UnixStamp 时间转成秒(只需要秒/Database中的datetime)
func (UnixStamp) MarshalJSON ¶
MarshalJSON marshal json
func (*UnixStamp) UnmarshalJSON ¶
UnmarshalJSON unmarshal json