I'm trying to make a Google Analytics Go library based off the auto generated package generated here
I have authenticated, got account summaries etc. so all is well until I try to construct a reporting request.
I am trying to init a struct ReportRequest that has the following:
type ReportRequest struct {
DateRanges []*DateRange `json:"dateRanges,omitempty"`
...etc
}
How can I made a function that wraps this struct so I can pass in the values? Consulting the DateRange struct it seems simple enough, but I get messages about not passing in a slice pointer to DateRange which I can't figure out how to construct.
I have tried this:
func makeRequest(
start, end string) *ga.GetReportsRequest {
daterangep := &ga.DateRange{StartDate: start, EndDate: end}
requests := ga.ReportRequest{}
requests.DateRanges = daterangep
But get a compiler error:
cannot use daterangep (type *analyticsreporting.DateRange) as type []*analyticsreporting.DateRange in assignment
Is it possible to send in JSON? I see some MarshalJSON functions that I don't know if I can use,and the json declaration in the object but I'd prefer to be able to use Go objects.
Can anyone point to what I'm doing wrong?