From: Matt Joiner Date: Thu, 31 Aug 2017 04:30:53 +0000 (+1000) Subject: Add peer_protocol.Message.MustMarshalBinary X-Git-Tag: v1.0.0~422 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3eb422afd0771e615898bdf5ae66e1c58edce3ed;p=btrtrc.git Add peer_protocol.Message.MustMarshalBinary --- diff --git a/peer_protocol/protocol.go b/peer_protocol/protocol.go index f1f392f9..19db34fb 100644 --- a/peer_protocol/protocol.go +++ b/peer_protocol/protocol.go @@ -68,6 +68,14 @@ type Message struct { Port uint16 } +func (msg Message) MustMarshalBinary() []byte { + b, err := msg.MarshalBinary() + if err != nil { + panic(err) + } + return b +} + func (msg Message) MarshalBinary() (data []byte, err error) { buf := &bytes.Buffer{} if !msg.Keepalive {