Ensure methods are not exported

This commit is contained in:
Tobie Morgan Hitchcock 2016-10-14 07:52:00 +01:00
parent d6cc391ee7
commit f90554c0b5
2 changed files with 75 additions and 75 deletions

View file

@ -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)
}

View file

@ -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)