deprecated.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package proto
  5. import (
  6. "encoding/json"
  7. "errors"
  8. "fmt"
  9. "strconv"
  10. )
  11. // Deprecated: Do not use.
  12. var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
  13. // Deprecated: Do not use.
  14. type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 }
  15. // Deprecated: Do not use.
  16. func GetStats() Stats { return Stats{} }
  17. // Deprecated: Do not use.
  18. func MarshalMessageSet(interface{}) ([]byte, error) {
  19. return nil, errors.New("proto: not implemented")
  20. }
  21. // Deprecated: Do not use.
  22. func UnmarshalMessageSet([]byte, interface{}) error {
  23. return errors.New("proto: not implemented")
  24. }
  25. // Deprecated: Do not use.
  26. func MarshalMessageSetJSON(interface{}) ([]byte, error) {
  27. return nil, errors.New("proto: not implemented")
  28. }
  29. // Deprecated: Do not use.
  30. func UnmarshalMessageSetJSON([]byte, interface{}) error {
  31. return errors.New("proto: not implemented")
  32. }
  33. // Deprecated: Do not use.
  34. func RegisterMessageSetType(Message, int32, string) {}
  35. // Deprecated: Do not use.
  36. func EnumName(m map[int32]string, v int32) string {
  37. if s, ok := m[v]; ok {
  38. return s
  39. }
  40. return strconv.Itoa(int(v))
  41. }
  42. // Deprecated: Do not use.
  43. func UnmarshalJSONEnum(m map[string]int32, b []byte, enumName string) (int32, error) {
  44. if b[0] == '"' {
  45. var s string
  46. if err := json.Unmarshal(b, &s); err != nil {
  47. return 0, fmt.Errorf("proto: invalid input for enum %v: %s", enumName, b)
  48. }
  49. v, ok := m[s]
  50. if !ok {
  51. return 0, fmt.Errorf("proto: invalid value for enum %v: %s", enumName, b)
  52. }
  53. return v, nil
  54. } else {
  55. var v int32
  56. if err := json.Unmarshal(b, &v); err != nil {
  57. return 0, fmt.Errorf("proto: invalid input for enum %v: %s", enumName, b)
  58. }
  59. return v, nil
  60. }
  61. }