Skip to content

Commit c400937

Browse files
authored
docs: Use pkgsite links (#3591)
1 parent 3875849 commit c400937

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

github/doc.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ The services of a client divide the API into logical chunks and correspond to
3131
the structure of the GitHub API documentation at
3232
https://docs.github.com/rest .
3333
34-
NOTE: Using the https://pkg.go.dev/context package, one can easily
34+
NOTE: Using the [context] package, one can easily
3535
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]
3737
can be used as a starting point.
3838
3939
For more sample code snippets, head over to the https://github.com/google/go-github/tree/master/example directory.
4040
4141
# Authentication
4242
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
4444
(for example, a personal access token). This is what is needed for a majority of use cases
4545
aside from GitHub Apps.
4646
4747
client := github.NewClient(nil).WithAuthToken("... your access token ...")
4848
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
5050
include the specified OAuth token. Therefore, authenticated clients should
5151
almost never be shared between different users.
5252
5353
For API methods that require HTTP Basic Authentication, use the
54-
BasicAuthTransport.
54+
[BasicAuthTransport].
5555
5656
GitHub Apps authentication can be provided by the
5757
https://github.com/bradleyfalzon/ghinstallation package.
@@ -100,15 +100,15 @@ limited to 60 requests per hour, while authenticated clients can make up to
100100
clients are limited to 10 requests per minute, while authenticated clients
101101
can make up to 30 requests per minute. To receive the higher rate limit when
102102
making calls that are not issued on behalf of a user,
103-
use UnauthenticatedRateLimitedTransport.
103+
use [UnauthenticatedRateLimitedTransport].
104104
105-
The returned Response.Rate value contains the rate limit information
105+
The returned [Response].[Rate] value contains the rate limit information
106106
from the most recent API call. If a recent enough response isn't
107107
available, you can use RateLimits to fetch the most up-to-date rate
108108
limit data for the client.
109109
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]:
112112
113113
repos, _, err := client.Repositories.List(ctx, "", nil)
114114
if _, ok := err.(*github.RateLimitError); ok {
@@ -129,7 +129,7 @@ the GitHub side. Methods known to behave like this are documented specifying
129129
this behavior.
130130
131131
To detect this condition of error, you can check if its type is
132-
*github.AcceptedError:
132+
*[AcceptedError]:
133133
134134
stats, _, err := client.Repositories.ListContributorsStats(ctx, org, repo)
135135
if _, ok := err.(*github.AcceptedError); ok {
@@ -142,7 +142,7 @@ The GitHub REST API has good support for conditional HTTP requests
142142
via the ETag header which will help prevent you from burning through your
143143
rate limit, as well as help speed up your application. go-github does not
144144
handle conditional requests directly, but is instead designed to work with a
145-
caching http.Transport.
145+
caching [http.Transport].
146146
147147
Typically, an RFC 7234 compliant HTTP cache such as https://github.com/gregjones/httpcache
148148
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
157157
158158
All structs for GitHub resources use pointer values for all non-repeated fields.
159159
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,
161161
bool, and int values. For example:
162162
163163
// create a new private repository named "foo"
@@ -173,10 +173,10 @@ Users who have worked with protocol buffers should find this pattern familiar.
173173
174174
All requests for resource collections (repos, pull requests, issues, etc.)
175175
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
177177
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.
180180
181181
client := github.NewClient(nil)
182182

github/github.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,12 +1391,12 @@ func (e *Error) UnmarshalJSON(data []byte) error {
13911391
// present. A response is considered an error if it has a status code outside
13921392
// the 200 range or equal to 202 Accepted.
13931393
// API error responses are expected to have response
1394-
// body, and a JSON response body that maps to ErrorResponse.
1394+
// body, and a JSON response body that maps to [ErrorResponse].
13951395
//
1396-
// The error type will be *RateLimitError for rate limit exceeded errors,
1397-
// *AcceptedError for 202 Accepted status codes,
1398-
// *TwoFactorAuthError for two-factor authentication errors,
1399-
// and *RedirectionError for redirect status codes (only happens when ignoring redirections).
1396+
// The error type will be *[RateLimitError] for rate limit exceeded errors,
1397+
// *[AcceptedError] for 202 Accepted status codes,
1398+
// *[TwoFactorAuthError] for two-factor authentication errors,
1399+
// and *[RedirectionError] for redirect status codes (only happens when ignoring redirections).
14001400
func CheckResponse(r *http.Response) error {
14011401
if r.StatusCode == http.StatusAccepted {
14021402
return &AcceptedError{}

github/messages.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ func messageMAC(signature string) ([]byte, func() hash.Hash, error) {
186186
// Example usage:
187187
//
188188
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
189-
// // read signature from request
190-
// signature := ""
191-
// payload, err := github.ValidatePayloadFromBody(r.Header.Get("Content-Type"), r.Body, signature, s.webhookSecretKey)
192-
// if err != nil { ... }
193-
// // Process payload...
189+
// // read signature from request
190+
// signature := ""
191+
// payload, err := github.ValidatePayloadFromBody(r.Header.Get("Content-Type"), r.Body, signature, s.webhookSecretKey)
192+
// if err != nil { ... }
193+
// // Process payload...
194194
// }
195195
func ValidatePayloadFromBody(contentType string, readable io.Reader, signature string, secretToken []byte) (payload []byte, err error) {
196196
var body []byte // Raw body that GitHub uses to calculate the signature.
@@ -249,9 +249,9 @@ func ValidatePayloadFromBody(contentType string, readable io.Reader, signature s
249249
// Example usage:
250250
//
251251
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
252-
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
253-
// if err != nil { ... }
254-
// // Process payload...
252+
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
253+
// if err != nil { ... }
254+
// // Process payload...
255255
// }
256256
func ValidatePayload(r *http.Request, secretToken []byte) (payload []byte, err error) {
257257
signature := r.Header.Get(SHA256SignatureHeader)
@@ -300,23 +300,23 @@ func DeliveryID(r *http.Request) string {
300300

301301
// ParseWebHook parses the event payload. For recognized event types, a
302302
// value of the corresponding struct type will be returned (as returned
303-
// by Event.ParsePayload()). An error will be returned for unrecognized event
303+
// by [Event.ParsePayload]). An error will be returned for unrecognized event
304304
// types.
305305
//
306306
// Example usage:
307307
//
308308
// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) {
309-
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
310-
// if err != nil { ... }
311-
// event, err := github.ParseWebHook(github.WebHookType(r), payload)
312-
// if err != nil { ... }
313-
// switch event := event.(type) {
314-
// case *github.CommitCommentEvent:
315-
// processCommitCommentEvent(event)
316-
// case *github.CreateEvent:
317-
// processCreateEvent(event)
318-
// ...
319-
// }
309+
// payload, err := github.ValidatePayload(r, s.webhookSecretKey)
310+
// if err != nil { ... }
311+
// event, err := github.ParseWebHook(github.WebHookType(r), payload)
312+
// if err != nil { ... }
313+
// switch event := event.(type) {
314+
// case *github.CommitCommentEvent:
315+
// processCommitCommentEvent(event)
316+
// case *github.CreateEvent:
317+
// processCreateEvent(event)
318+
// ...
319+
// }
320320
// }
321321
func ParseWebHook(messageType string, payload []byte) (any, error) {
322322
eventType, ok := messageToTypeName[messageType]

0 commit comments

Comments
 (0)