Deprecated: Do not use.
(m map[string]int32, data []byte, enumName string)
| 64 | |
| 65 | // Deprecated: Do not use. |
| 66 | func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) { |
| 67 | if data[0] == '"' { |
| 68 | // New style: enums are strings. |
| 69 | var repr string |
| 70 | if err := json.Unmarshal(data, &repr); err != nil { |
| 71 | return -1, err |
| 72 | } |
| 73 | val, ok := m[repr] |
| 74 | if !ok { |
| 75 | return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr) |
| 76 | } |
| 77 | return val, nil |
| 78 | } |
| 79 | // Old style: enums are ints. |
| 80 | var val int32 |
| 81 | if err := json.Unmarshal(data, &val); err != nil { |
| 82 | return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName) |
| 83 | } |
| 84 | return val, nil |
| 85 | } |
| 86 | |
| 87 | // Deprecated: Do not use; this type existed for intenal-use only. |
| 88 | type InternalMessageInfo struct{} |
no test coverage detected