marshal.go 485 B

1234567891011121314151617181920
  1. // Copyright (C) 2015 The GoHBase Authors. All rights reserved.
  2. // This file is part of GoHBase.
  3. // Use of this source code is governed by the Apache License 2.0
  4. // that can be found in the COPYING file.
  5. package pb
  6. import (
  7. "github.com/golang/protobuf/proto"
  8. )
  9. // MustMarshal is like proto.Marshal except it panic()'s if the protobuf
  10. // couldn't be serialized.
  11. func MustMarshal(pb proto.Message) []byte {
  12. b, err := proto.Marshal(pb)
  13. if err != nil {
  14. panic(err)
  15. }
  16. return b
  17. }