Ensure methods are not exported
This commit is contained in:
parent
d6cc391ee7
commit
f90554c0b5
2 changed files with 75 additions and 75 deletions
112
util/keys/enc.go
112
util/keys/enc.go
|
@ -45,29 +45,29 @@ func (e *encoder) Encode(items ...interface{}) {
|
||||||
|
|
||||||
case nil:
|
case nil:
|
||||||
|
|
||||||
e.w.Write(bNIL)
|
e.w.write(bNIL)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case bool:
|
case bool:
|
||||||
|
|
||||||
e.w.Write(bVAL)
|
e.w.write(bVAL)
|
||||||
if value {
|
if value {
|
||||||
e.w.Write(bVAL)
|
e.w.write(bVAL)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case time.Time:
|
case time.Time:
|
||||||
|
|
||||||
e.w.Write(bTME)
|
e.w.write(bTME)
|
||||||
e.w.Write(value)
|
e.w.write(value)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []byte:
|
case []byte:
|
||||||
|
|
||||||
e.w.Write(bSTR)
|
e.w.write(bSTR)
|
||||||
e.w.Write(value)
|
e.w.write(value)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case string:
|
case string:
|
||||||
|
|
||||||
|
@ -76,156 +76,156 @@ func (e *encoder) Encode(items ...interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if value == Prefix {
|
if value == Prefix {
|
||||||
e.w.Write(bPRE)
|
e.w.write(bPRE)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if value == Suffix {
|
if value == Suffix {
|
||||||
e.w.Write(bSUF)
|
e.w.write(bSUF)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
e.w.Write(bSTR)
|
e.w.write(bSTR)
|
||||||
e.w.Write(value)
|
e.w.write(value)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case float32, float64:
|
case float32, float64:
|
||||||
|
|
||||||
e.w.Write(value)
|
e.w.write(value)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case int, int8, int16, int32, int64:
|
case int, int8, int16, int32, int64:
|
||||||
|
|
||||||
e.w.Write(value)
|
e.w.write(value)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case uint, uint8, uint16, uint32, uint64:
|
case uint, uint8, uint16, uint32, uint64:
|
||||||
|
|
||||||
e.w.Write(value)
|
e.w.write(value)
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []time.Time:
|
case []time.Time:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []bool:
|
case []bool:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []string:
|
case []string:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []int:
|
case []int:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []int8:
|
case []int8:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []int16:
|
case []int16:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []int32:
|
case []int32:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []int64:
|
case []int64:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []uint:
|
case []uint:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []uint16:
|
case []uint16:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []uint32:
|
case []uint32:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []uint64:
|
case []uint64:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []float32:
|
case []float32:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []float64:
|
case []float64:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
|
|
||||||
e.w.Write(bARR)
|
e.w.write(bARR)
|
||||||
for _, val := range value {
|
for _, val := range value {
|
||||||
e.Encode(val)
|
e.Encode(val)
|
||||||
}
|
}
|
||||||
e.w.Write(bEND)
|
e.w.write(bEND)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,62 +33,62 @@ func newWriter(w io.Writer) *writer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *writer) Write(i interface{}) {
|
func (w *writer) write(i interface{}) {
|
||||||
|
|
||||||
switch v := i.(type) {
|
switch v := i.(type) {
|
||||||
|
|
||||||
case []byte:
|
case []byte:
|
||||||
w.Writer.Write(v)
|
w.Write(v)
|
||||||
|
|
||||||
case string:
|
case string:
|
||||||
w.writeString(v)
|
w.writeStr(v)
|
||||||
|
|
||||||
case time.Time:
|
case time.Time:
|
||||||
w.writeTime(v)
|
w.writeTme(v)
|
||||||
|
|
||||||
case uint:
|
case uint:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case uint8:
|
case uint8:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case uint16:
|
case uint16:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case uint32:
|
case uint32:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case uint64:
|
case uint64:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
|
|
||||||
case int:
|
case int:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case int8:
|
case int8:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case int16:
|
case int16:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case int32:
|
case int32:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case int64:
|
case int64:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
|
|
||||||
case float32:
|
case float32:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
case float64:
|
case float64:
|
||||||
w.writeNumber(float64(v))
|
w.writeNum(float64(v))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *writer) writeString(v string) {
|
func (w *writer) writeStr(v string) {
|
||||||
b := *(*[]byte)(unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&v))))
|
b := *(*[]byte)(unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&v))))
|
||||||
w.Write(b)
|
w.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *writer) writeTime(v time.Time) {
|
func (w *writer) writeTme(v time.Time) {
|
||||||
b := make([]byte, 8)
|
b := make([]byte, 8)
|
||||||
binary.BigEndian.PutUint64(b, uint64(v.UTC().UnixNano()))
|
binary.BigEndian.PutUint64(b, uint64(v.UTC().UnixNano()))
|
||||||
w.Write(b)
|
w.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *writer) writeNumber(v float64) {
|
func (w *writer) writeNum(v float64) {
|
||||||
b := make([]byte, 8)
|
b := make([]byte, 8)
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
w.Write(bNEG)
|
w.Write(bNEG)
|
||||||
|
|
Loading…
Reference in a new issue