diff --git a/crypto/secio/protocol.go b/crypto/secio/protocol.go index 73cb5fdf0..b51197202 100644 --- a/crypto/secio/protocol.go +++ b/crypto/secio/protocol.go @@ -218,7 +218,7 @@ func (s *secureSession) runHandshake() error { s.local.ephemeralPubKey, genSharedKey, err = ci.GenerateEKeyPair(s.local.curveT) // Gather corpus to sign. - var selectionOut bytes.Buffer + selectionOut := new(bytes.Buffer) selectionOut.Write(proposeOutBytes) selectionOut.Write(proposeInBytes) selectionOut.Write(s.local.ephemeralPubKey) @@ -249,7 +249,7 @@ func (s *secureSession) runHandshake() error { // get their ephemeral pub key s.remote.ephemeralPubKey = exchangeIn.GetEpubkey() - var selectionIn bytes.Buffer + selectionIn := new(bytes.Buffer) selectionIn.Write(proposeInBytes) selectionIn.Write(proposeOutBytes) selectionIn.Write(s.remote.ephemeralPubKey) diff --git a/protocol/mux_test.go b/protocol/mux_test.go index 68cdb1175..9e3b24552 100644 --- a/protocol/mux_test.go +++ b/protocol/mux_test.go @@ -16,8 +16,8 @@ var testCases = map[string]string{ func TestWrite(t *testing.T) { for k, v := range testCases { - var buf bytes.Buffer - if err := WriteHeader(&buf, ID(k)); err != nil { + buf := new(bytes.Buffer) + if err := WriteHeader(buf, ID(k)); err != nil { t.Fatal(err) } @@ -46,13 +46,13 @@ func TestHandler(t *testing.T) { m.SetHandler("/ipfs/dksnafkasnfkdajfkdajfdsjadosiaaodj", h("bitswap")) for k, v := range testCases { - var buf bytes.Buffer + buf := new(bytes.Buffer) if _, err := buf.Write([]byte(v)); err != nil { t.Error(err) continue } - name, err := ReadHeader(&buf) + name, err := ReadHeader(buf) if err != nil { t.Error(err) continue