]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add peer_protocol.Message.MustMarshalBinary
authorMatt Joiner <anacrolix@gmail.com>
Thu, 31 Aug 2017 04:30:53 +0000 (14:30 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 31 Aug 2017 04:30:53 +0000 (14:30 +1000)
peer_protocol/protocol.go

index f1f392f9a9c414d3ebb5702b38f77db29ff85c62..19db34fb259d49cc4a09b600ab31ef3443aa0096 100644 (file)
@@ -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 {