toNormalizedJSON removes fake random space from proto JSON original marshaller. It is required, so we can compare proto messages in json format. Read more in https://github.com/golang/protobuf/issues/1121
(m proto.Message)
| 51 | // It is required, so we can compare proto messages in json format. |
| 52 | // Read more in https://github.com/golang/protobuf/issues/1121 |
| 53 | func toNormalizedJSON(m proto.Message) string { |
| 54 | mAsJSON, err := protojson.Marshal(m) |
| 55 | if err != nil { |
| 56 | panic(err) |
| 57 | } |
| 58 | |
| 59 | buffer := new(bytes.Buffer) |
| 60 | if err := json.Compact(buffer, mAsJSON); err != nil { |
| 61 | panic(err) |
| 62 | } |
| 63 | return buffer.String() |
| 64 | } |
no test coverage detected