Skip to content

Commit 5a60878

Browse files
committed
docs: Improve formatting in README
1 parent e56d378 commit 5a60878

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

README.md

+37-37
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# go-github #
22

33
[![go-github release (latest SemVer)](https://img.shields.io/github/v/release/google/go-github?sort=semver)](https://github.com/google/go-github/releases)
4-
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v65/github)
4+
[![Go Reference](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v65/github)
55
[![Test Status](https://github.com/google/go-github/workflows/tests/badge.svg)](https://github.com/google/go-github/actions?query=workflow%3Atests)
66
[![Test Coverage](https://codecov.io/gh/google/go-github/branch/master/graph/badge.svg)](https://codecov.io/gh/google/go-github)
77
[![Discuss at [email protected]](https://img.shields.io/badge/discuss-go--github%40googlegroups.com-blue.svg)](https://groups.google.com/group/go-github)
88
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/796/badge)](https://bestpractices.coreinfrastructure.org/projects/796)
99

1010
go-github is a Go client library for accessing the [GitHub API v3][].
1111

12-
Currently, **go-github requires Go version 1.13 or greater**. go-github tracks
12+
Currently, **go-github requires Go version 1.21 or greater**. go-github tracks
1313
[Go's version support policy][support-policy]. We do our best not to break
1414
older versions of Go if we don't have to, but due to tooling constraints, we
1515
don't always test older versions.
@@ -71,10 +71,9 @@ repos, _, err := client.Repositories.ListByOrg(context.Background(), "github", o
7171
```
7272

7373
The services of a client divide the API into logical chunks and correspond to
74-
the structure of the GitHub API documentation at
75-
https://docs.github.com/en/rest .
74+
the structure of the [GitHub API documentation](https://docs.github.com/en/rest).
7675

77-
NOTE: Using the [context](https://godoc.org/context) package, one can easily
76+
NOTE: Using the [context](https://pkg.go.dev/context) package, one can easily
7877
pass cancelation signals and deadlines to various services of the client for
7978
handling a request. In case there is no context available, then `context.Background()`
8079
can be used as a starting point.
@@ -97,11 +96,12 @@ include the specified OAuth token. Therefore, authenticated clients should
9796
almost never be shared between different users.
9897

9998
For API methods that require HTTP Basic Authentication, use the
100-
[`BasicAuthTransport`](https://godoc.org/github.com/google/go-github/github#BasicAuthTransport).
99+
[`BasicAuthTransport`](https://pkg.go.dev/github.com/google/go-github/github#BasicAuthTransport).
101100

102101
#### As a GitHub App ####
103102

104-
GitHub Apps authentication can be provided by different pkgs like [ghinstallation](https://github.com/bradleyfalzon/ghinstallation) or [go-githubauth](https://github.com/jferrl/go-githubauth).
103+
GitHub Apps authentication can be provided by different pkgs like [bradleyfalzon/ghinstallation](https://github.com/bradleyfalzon/ghinstallation)
104+
or [jferrl/go-githubauth](https://github.com/jferrl/go-githubauth).
105105

106106
> **Note**: Most endpoints (ex. [`GET /rate_limit`]) require access token authentication
107107
> while a few others (ex. [`GET /app/hook/deliveries`]) require [JWT] authentication.
@@ -148,33 +148,33 @@ Other example using `go-githubauth`:
148148
package main
149149

150150
import (
151-
"context"
152-
"fmt"
153-
"os"
154-
"strconv"
155-
156-
"github.com/google/go-github/v65/github"
157-
"github.com/jferrl/go-githubauth"
158-
"golang.org/x/oauth2"
151+
"context"
152+
"fmt"
153+
"os"
154+
"strconv"
155+
156+
"github.com/google/go-github/v65/github"
157+
"github.com/jferrl/go-githubauth"
158+
"golang.org/x/oauth2"
159159
)
160160

161161
func main() {
162-
privateKey := []byte(os.Getenv("GITHUB_APP_PRIVATE_KEY"))
162+
privateKey := []byte(os.Getenv("GITHUB_APP_PRIVATE_KEY"))
163163

164-
appTokenSource, err := githubauth.NewApplicationTokenSource(1112, privateKey)
165-
if err != nil {
166-
fmt.Println("Error creating application token source:", err)
167-
return
168-
}
164+
appTokenSource, err := githubauth.NewApplicationTokenSource(1112, privateKey)
165+
if err != nil {
166+
fmt.Println("Error creating application token source:", err)
167+
return
168+
}
169169

170-
installationTokenSource := githubauth.NewInstallationTokenSource(1113, appTokenSource)
170+
installationTokenSource := githubauth.NewInstallationTokenSource(1113, appTokenSource)
171171

172-
// oauth2.NewClient uses oauth2.ReuseTokenSource to reuse the token until it expires.
173-
// The token will be automatically refreshed when it expires.
174-
// InstallationTokenSource has the mechanism to refresh the token when it expires.
175-
httpClient := oauth2.NewClient(context.Background(), installationTokenSource)
172+
// oauth2.NewClient uses oauth2.ReuseTokenSource to reuse the token until it expires.
173+
// The token will be automatically refreshed when it expires.
174+
// InstallationTokenSource has the mechanism to refresh the token when it expires.
175+
httpClient := oauth2.NewClient(context.Background(), installationTokenSource)
176176

177-
client := github.NewClient(httpClient)
177+
client := github.NewClient(httpClient)
178178
}
179179
```
180180

@@ -205,8 +205,7 @@ if _, ok := err.(*github.RateLimitError); ok {
205205
}
206206
```
207207

208-
Learn more about GitHub rate limiting at
209-
https://docs.github.com/en/rest/rate-limit .
208+
Learn more about GitHub rate limiting in the ["REST API endpoints for rate limits"](https://docs.github.com/en/rest/rate-limit).
210209

211210
In addition to these rate limits, GitHub imposes a secondary rate limit on all API clients.
212211
This rate limit prevents clients from making too many concurrent requests.
@@ -226,11 +225,11 @@ Alternatively, you can block until the rate limit is reset by using the `context
226225
repos, _, err := client.Repositories.List(context.WithValue(ctx, github.SleepUntilPrimaryRateLimitResetWhenRateLimited, true), "", nil)
227226
```
228227

229-
You can use [go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) to handle
228+
You can use [gofri/go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) to handle
230229
secondary rate limit sleep-and-retry for you.
231230

232-
Learn more about GitHub secondary rate limiting at
233-
https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#about-secondary-rate-limits .
231+
Learn more about GitHub secondary rate limiting in the
232+
["About secondary rate limits"](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#about-secondary-rate-limits).
234233

235234
### Accepted Status ###
236235

@@ -255,7 +254,7 @@ The GitHub API has good support for conditional requests which will help
255254
prevent you from burning through your rate limit, as well as help speed up your
256255
application. `go-github` does not handle conditional requests directly, but is
257256
instead designed to work with a caching `http.Transport`. We recommend using
258-
https://github.com/gregjones/httpcache for that. For example:
257+
[gregjones/httpcache](https://github.com/gregjones/httpcache) for that. For example:
259258

260259
```go
261260
import "github.com/gregjones/httpcache"
@@ -265,8 +264,8 @@ import "github.com/gregjones/httpcache"
265264
).WithAuthToken(os.Getenv("GITHUB_TOKEN"))
266265
```
267266

268-
Learn more about GitHub conditional requests at
269-
https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#use-conditional-requests-if-appropriate
267+
Learn more about GitHub conditional requests in the
268+
["Use conditional requests if appropriate"](https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#use-conditional-requests-if-appropriate).
270269

271270
### Creating and Updating Resources ###
272271

@@ -316,7 +315,7 @@ for {
316315
}
317316
```
318317

319-
#### Iterators (**experimental**)
318+
#### Iterators (**experimental**) ####
320319

321320
Go v1.23 introduces the new `iter` package.
322321

@@ -367,7 +366,7 @@ For complete usage of go-github, see the full [package docs][].
367366
[GitHub webhook events]: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads
368367
[cbrgm/githubevents]: https://github.com/cbrgm/githubevents
369368

370-
### Testing code that uses `go-github`
369+
### Testing code that uses `go-github` ###
371370

372371
The repo [migueleliasweb/go-github-mock](https://github.com/migueleliasweb/go-github-mock) provides a way to mock responses. Check the repo for more details.
373372

@@ -376,6 +375,7 @@ The repo [migueleliasweb/go-github-mock](https://github.com/migueleliasweb/go-gi
376375
You can run integration tests from the `test` directory. See the integration tests [README](test/README.md).
377376

378377
## Contributing ##
378+
379379
I would like to cover the entire GitHub API and contributions are of course always welcome. The
380380
calling pattern is pretty well established, so adding new methods is relatively
381381
straightforward. See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details.

0 commit comments

Comments
 (0)