I have a problem that I am not sure how to solve in Go. I need to make a client that talks to a json based api.
So I thought that I would use composition to build the struct similar to below.
type (
BaseData struct {
CommonFields string
}
Data struct {
BaseData
Result string
}
)
Now I would send the Data struct to the api and unmarshal the response to the results, all good so far.
Now the issue is that I have different requests to send that require a different "results" composition and therefore would need to have many definitions of the Data struct in the same package, which is no good.
I am struggling to see how this should be done. Any pointers in a direction will great.