MarshalOrPanic serializes a protobuf message and panics if this operation fails
(pb proto.Message)
| 20 | // MarshalOrPanic serializes a protobuf message and panics if this |
| 21 | // operation fails |
| 22 | func MarshalOrPanic(pb proto.Message) []byte { |
| 23 | if !pb.ProtoReflect().IsValid() { |
| 24 | panic(errors.New("proto: Marshal called with nil")) |
| 25 | } |
| 26 | data, err := proto.Marshal(pb) |
| 27 | if err != nil { |
| 28 | panic(err) |
| 29 | } |
| 30 | return data |
| 31 | } |
| 32 | |
| 33 | // Marshal serializes a protobuf message. |
| 34 | func Marshal(pb proto.Message) ([]byte, error) { |