From f90554c0b5da3955b50404a79943fb0eba787055 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 14 Oct 2016 07:52:00 +0100 Subject: [PATCH] Ensure methods are not exported --- util/keys/enc.go | 112 ++++++++++++++++++++++---------------------- util/keys/writer.go | 38 +++++++-------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/util/keys/enc.go b/util/keys/enc.go index 4b59b55c..31660e92 100644 --- a/util/keys/enc.go +++ b/util/keys/enc.go @@ -45,29 +45,29 @@ func (e *encoder) Encode(items ...interface{}) { case nil: - e.w.Write(bNIL) - e.w.Write(bEND) + e.w.write(bNIL) + e.w.write(bEND) case bool: - e.w.Write(bVAL) + e.w.write(bVAL) if value { - e.w.Write(bVAL) + e.w.write(bVAL) } - e.w.Write(bEND) + e.w.write(bEND) case time.Time: - e.w.Write(bTME) - e.w.Write(value) - e.w.Write(bEND) + e.w.write(bTME) + e.w.write(value) + e.w.write(bEND) case []byte: - e.w.Write(bSTR) - e.w.Write(value) - e.w.Write(bEND) - e.w.Write(bEND) + e.w.write(bSTR) + e.w.write(value) + e.w.write(bEND) + e.w.write(bEND) case string: @@ -76,156 +76,156 @@ func (e *encoder) Encode(items ...interface{}) { } if value == Prefix { - e.w.Write(bPRE) - e.w.Write(bEND) + e.w.write(bPRE) + e.w.write(bEND) break } if value == Suffix { - e.w.Write(bSUF) - e.w.Write(bEND) + e.w.write(bSUF) + e.w.write(bEND) break } - e.w.Write(bSTR) - e.w.Write(value) - e.w.Write(bEND) - e.w.Write(bEND) + e.w.write(bSTR) + e.w.write(value) + e.w.write(bEND) + e.w.write(bEND) case float32, float64: - e.w.Write(value) - e.w.Write(bEND) + e.w.write(value) + e.w.write(bEND) case int, int8, int16, int32, int64: - e.w.Write(value) - e.w.Write(bEND) + e.w.write(value) + e.w.write(bEND) case uint, uint8, uint16, uint32, uint64: - e.w.Write(value) - e.w.Write(bEND) + e.w.write(value) + e.w.write(bEND) case []time.Time: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []bool: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []string: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []int: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []int8: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []int16: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []int32: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []int64: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []uint: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []uint16: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []uint32: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []uint64: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []float32: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []float64: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) case []interface{}: - e.w.Write(bARR) + e.w.write(bARR) for _, val := range value { e.Encode(val) } - e.w.Write(bEND) + e.w.write(bEND) } diff --git a/util/keys/writer.go b/util/keys/writer.go index 05512ad8..fad7456b 100644 --- a/util/keys/writer.go +++ b/util/keys/writer.go @@ -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) { case []byte: - w.Writer.Write(v) + w.Write(v) case string: - w.writeString(v) + w.writeStr(v) case time.Time: - w.writeTime(v) + w.writeTme(v) case uint: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case uint8: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case uint16: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case uint32: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case uint64: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case int: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case int8: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case int16: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case int32: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case int64: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) case float32: - w.writeNumber(float64(v)) + w.writeNum(float64(v)) 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)))) w.Write(b) } -func (w *writer) writeTime(v time.Time) { +func (w *writer) writeTme(v time.Time) { b := make([]byte, 8) binary.BigEndian.PutUint64(b, uint64(v.UTC().UnixNano())) w.Write(b) } -func (w *writer) writeNumber(v float64) { +func (w *writer) writeNum(v float64) { b := make([]byte, 8) if v < 0 { w.Write(bNEG)