MCPcopy Index your code
hub / github.com/google/go-github / Do

Method Do

github/github.go:1328–1349  ·  view source on GitHub ↗

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decod

(req *http.Request, v any)

Source from the content-addressed store, hash-verified

1326// If rate limit is exceeded and reset time is in the future, Do returns
1327// *RateLimitError immediately without making a network API call.
1328func (c *Client) Do(req *http.Request, v any) (*Response, error) {
1329 resp, err := c.BareDo(req)
1330 if err != nil {
1331 return resp, err
1332 }
1333 defer resp.Body.Close()
1334
1335 switch v := v.(type) {
1336 case nil:
1337 case io.Writer:
1338 _, err = io.Copy(v, resp.Body)
1339 default:
1340 decErr := json.NewDecoder(resp.Body).Decode(v)
1341 if decErr == io.EOF {
1342 decErr = nil // ignore EOF errors caused by empty response body
1343 }
1344 if decErr != nil {
1345 err = decErr
1346 }
1347 }
1348 return resp, err
1349}
1350
1351// checkRateLimitBeforeDo does not make any network calls, but uses existing knowledge from
1352// current client state in order to quickly check if *RateLimitError can be immediately returned

Callers 15

StartUserMigrationMethod · 0.45
ListUserMigrationsMethod · 0.45
UserMigrationStatusMethod · 0.45
DeleteUserMigrationMethod · 0.45
UnlockUserRepoMethod · 0.45
ListBudgetsMethod · 0.45
CreateBudgetMethod · 0.45
GetBudgetMethod · 0.45
UpdateBudgetMethod · 0.45
DeleteBudgetMethod · 0.45
ListRulesForBranchMethod · 0.45

Calls 2

BareDoMethod · 0.95
CloseMethod · 0.80