I am learning golang and want to write generic response from microservices response.
My General Response is like:
type GeneralResponse struct {
Success string
Message string
Data string
Error string
}
In the Data
section I want to return any json, say list of Person
, Instruments
or any type of objects.
But it should be another json. I tried assigning other json objects but it did not work. It is fine if I dump json array as string into it but it should unmarshal from receiver end. How should I go about it?
I am trying over here. https://play.golang.org/p/dc0uKtS76aA