I created a Logs Router Sink to export logs to a Pub/Sub. My Golang application is supposed to consume messages from this Pub/Sub via a dedicated Subscription using google client library (Golang).
The messages received on the Subscription are JSON representations of LogEntry objects.
The question: How to unmarshal the JSONs into useful Golang objects?
- my first attempt was to unmarshal the JSONs to Entry object. The attempt failed because this object has no JSON mappings for the fields, in particular
textPayload
JSON field was not unmarshalled - the second attempt was to unmarshal the JSONs to LogEntry object. This object seems to fit the definition, but its main purpose is protobufs (and not JSON). In particular when I tried to unmarshal a LogEntry JSON into it, I got the following error
cannot unmarshal string into Go struct field LogEntry.severity of type ltype.LogSeverity