Not sure if my question is worded as best as it can be but I'm writing an application that effectively translates a REST API into a binary (CAN Bus) protocol and am wondering how best to implement the translation between the two. At the moment I'm thinking of having a protocol Status struct made of 'message' objects each carrying the JSON value and the corresponding CAN Bus identifier and data but not sure this is as clean as it could be. I feel like maps make might sense here but not quite sure how to make sense of them in this instance. Thoughts?
Are you thinking about multiple possible types in a struct, something for which you might have used unions but since Go doesn't have unions you're looking for alternatives? If so that's covered in this answer about using an interface to implement to different types: https://stackoverflow.com/a/21567136/459