// fetch detailed information about the change func Get(gerrit *api.API, id string) (*LongChange, error) { change_url := url.URL{Scheme: "https", Host: gerrit.Host, Opaque: "/a/changes/" + id + "/detail/"} contents, err := gerrit.Fetch_json(&change_url) if err != nil { return nil, err } var data LongChange err = json.Unmarshal(contents, &data) if err != nil { return nil, err } return &data, nil }
// get list of changes according to the query string func FetchList(gerrit *api.API, query_string string) ([]ShortChange, error) { list_url, _ := url.Parse("https://" + gerrit.Host + "/a/changes/" + query_string) contents, err := gerrit.Fetch_json(list_url) if err != nil { return nil, err } var data []ShortChange err = json.Unmarshal(contents, &data) if err != nil { //fmt.Printf("JSON failed: %s\n", err) //fmt.Printf("JSON data is: %s\n", contents) return nil, err } return data, nil }