Use bytes.Reader instead of bytes.Buffer in a few places
This commit is contained in:
parent
c3768da38c
commit
9ded7e7e87
|
@ -130,7 +130,7 @@ func MustMarshal(v interface{}) []byte {
|
|||
// Unmarshal the bencode value in the 'data' to a value pointed by the 'v'
|
||||
// pointer, return a non-nil error if any.
|
||||
func Unmarshal(data []byte, v interface{}) (err error) {
|
||||
buf := bytes.NewBuffer(data)
|
||||
buf := bytes.NewReader(data)
|
||||
e := Decoder{r: buf}
|
||||
err = e.Decode(v)
|
||||
if err == nil && buf.Len() != 0 {
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestMarshalPexMessage(t *testing.T) {
|
|||
|
||||
msg = Message{}
|
||||
dec := Decoder{
|
||||
R: bufio.NewReader(bytes.NewBuffer(b)),
|
||||
R: bufio.NewReader(bytes.NewReader(b)),
|
||||
MaxLength: 128,
|
||||
}
|
||||
pmOut := PexMsg{}
|
||||
|
|
Loading…
Reference in New Issue