caio.co/de/go-tdigest

gometalinter: Use interfaces when it makes sense

There's now another suggestion:

    $ gometalinter ./... --disable=gocyclo
    serialization.go:63:16:warning: buf can be jpeg.Reader (interfacer)

But that's just too silly.

To be honest, I'm not so sure this is a sensical change even:
encodeUint and encodeUint are "private". bytes.{Buffer,Reader} is
precisely what I need and use throughout the implementation. So,
hashtag revertMeMaybe.
Id
2686af5cd15f0a8f4650e2a4a9bbf44c05b87e10
Author
Caio
Commit time
2016-08-17T21:04:26+02:00

Modified serialization.go

@@ -5,6 +5,7
"encoding/binary"
"errors"
"fmt"
+ "io"
)

const smallEncoding int32 = 2
@@ -115,7 +116,7
return t, nil
}

-func encodeUint(buf *bytes.Buffer, n uint32) error {
+func encodeUint(buf io.Writer, n uint32) error {
var b [binary.MaxVarintLen32]byte

l := binary.PutUvarint(b[:], uint64(n))
@@ -125,7 +126,7
return err
}

-func decodeUint(buf *bytes.Reader) (uint32, error) {
+func decodeUint(buf io.ByteReader) (uint32, error) {
v, err := binary.ReadUvarint(buf)
if v > 0xffffffff {
return 0, errors.New("Something wrong, this number looks too big")