@@ -31,27 +31,27 @@ The services of a client divide the API into logical chunks and correspond to
31
31
the structure of the GitHub API documentation at
32
32
https://docs.github.com/rest .
33
33
34
- NOTE: Using the https://pkg.go.dev/ context package, one can easily
34
+ NOTE: Using the [ context] package, one can easily
35
35
pass cancelation signals and deadlines to various services of the client for
36
- handling a request. In case there is no context available, then context.Background()
36
+ handling a request. In case there is no context available, then [ context.Background]
37
37
can be used as a starting point.
38
38
39
39
For more sample code snippets, head over to the https://github.com/google/go-github/tree/master/example directory.
40
40
41
41
# Authentication
42
42
43
- Use Client.WithAuthToken to configure your client to authenticate using an Oauth token
43
+ Use [ Client.WithAuthToken] to configure your client to authenticate using an Oauth token
44
44
(for example, a personal access token). This is what is needed for a majority of use cases
45
45
aside from GitHub Apps.
46
46
47
47
client := github.NewClient(nil).WithAuthToken("... your access token ...")
48
48
49
- Note that when using an authenticated Client, all calls made by the client will
49
+ Note that when using an authenticated [ Client] , all calls made by the client will
50
50
include the specified OAuth token. Therefore, authenticated clients should
51
51
almost never be shared between different users.
52
52
53
53
For API methods that require HTTP Basic Authentication, use the
54
- BasicAuthTransport.
54
+ [ BasicAuthTransport] .
55
55
56
56
GitHub Apps authentication can be provided by the
57
57
https://github.com/bradleyfalzon/ghinstallation package.
@@ -100,15 +100,15 @@ limited to 60 requests per hour, while authenticated clients can make up to
100
100
clients are limited to 10 requests per minute, while authenticated clients
101
101
can make up to 30 requests per minute. To receive the higher rate limit when
102
102
making calls that are not issued on behalf of a user,
103
- use UnauthenticatedRateLimitedTransport.
103
+ use [ UnauthenticatedRateLimitedTransport] .
104
104
105
- The returned Response. Rate value contains the rate limit information
105
+ The returned [ Response].[ Rate] value contains the rate limit information
106
106
from the most recent API call. If a recent enough response isn't
107
107
available, you can use RateLimits to fetch the most up-to-date rate
108
108
limit data for the client.
109
109
110
- To detect an API rate limit error, you can check if its type is *github. RateLimitError.
111
- For secondary rate limits, you can check if its type is *github. AbuseRateLimitError:
110
+ To detect an API rate limit error, you can check if its type is *[ RateLimitError] .
111
+ For secondary rate limits, you can check if its type is *[ AbuseRateLimitError] :
112
112
113
113
repos, _, err := client.Repositories.List(ctx, "", nil)
114
114
if _, ok := err.(*github.RateLimitError); ok {
@@ -129,7 +129,7 @@ the GitHub side. Methods known to behave like this are documented specifying
129
129
this behavior.
130
130
131
131
To detect this condition of error, you can check if its type is
132
- *github. AcceptedError:
132
+ *[ AcceptedError] :
133
133
134
134
stats, _, err := client.Repositories.ListContributorsStats(ctx, org, repo)
135
135
if _, ok := err.(*github.AcceptedError); ok {
@@ -142,7 +142,7 @@ The GitHub REST API has good support for conditional HTTP requests
142
142
via the ETag header which will help prevent you from burning through your
143
143
rate limit, as well as help speed up your application. go-github does not
144
144
handle conditional requests directly, but is instead designed to work with a
145
- caching http.Transport.
145
+ caching [ http.Transport] .
146
146
147
147
Typically, an RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache
148
148
is recommended. Alternatively, the https://github.com/bored-engineer/github-conditional-http-transport
@@ -157,7 +157,7 @@ https://docs.github.com/rest/overview/resources-in-the-rest-api#conditional-requ
157
157
158
158
All structs for GitHub resources use pointer values for all non-repeated fields.
159
159
This allows distinguishing between unset fields and those set to a zero-value.
160
- Helper functions have been provided to easily create these pointers for string,
160
+ A helper function, [Ptr], has been provided to easily create these pointers for string,
161
161
bool, and int values. For example:
162
162
163
163
// create a new private repository named "foo"
@@ -173,10 +173,10 @@ Users who have worked with protocol buffers should find this pattern familiar.
173
173
174
174
All requests for resource collections (repos, pull requests, issues, etc.)
175
175
support pagination. Pagination options are described in the
176
- github. ListOptions struct and passed to the list methods directly or as an
176
+ [ ListOptions] struct and passed to the list methods directly or as an
177
177
embedded type of a more specific list options struct (for example
178
- github. PullRequestListOptions). Pages information is available via the
179
- github. Response struct.
178
+ [ PullRequestListOptions] ). Pages information is available via the
179
+ [ Response] struct.
180
180
181
181
client := github.NewClient(nil)
182
182
0 commit comments