executeSearch performs a single GitHub Code Search API call.
(client *api.Client, host, query string, page, pageSize int)
| 727 | |
| 728 | // executeSearch performs a single GitHub Code Search API call. |
| 729 | func executeSearch(client *api.Client, host, query string, page, pageSize int) (*codeSearchResult, error) { |
| 730 | apiPath, err := safeurl.JoinPath("search", "code") |
| 731 | if err != nil { |
| 732 | return nil, err |
| 733 | } |
| 734 | apiPath.SetQuery("q", query) |
| 735 | apiPath.SetQuery("per_page", strconv.Itoa(pageSize)) |
| 736 | apiPath.SetQuery("page", strconv.Itoa(page)) |
| 737 | var result codeSearchResult |
| 738 | err = client.REST(host, "GET", apiPath.String(), nil, &result) |
| 739 | if err != nil && isRateLimitError(err) { |
| 740 | return nil, fmt.Errorf("%s", rateLimitErrorMessage) |
| 741 | } |
| 742 | return &result, err |
| 743 | } |
| 744 | |
| 745 | // fetchPrimaryPages fetches enough API pages from GitHub Code Search to |
| 746 | // cover the requested display page, accounting for filtering losses. |