-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue2929
- Loading branch information
Showing
143 changed files
with
4,961 additions
and
3,174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
run: | ||
build-tags: | ||
- integration | ||
linters: | ||
# TODO: fix errors so that all of the linters below pass. | ||
# The linters that are commented out, as well as those explicitly disabled, | ||
# are currently failing. We should fix those failures or define exclusion | ||
# rules, and then enable those linters. | ||
enable: | ||
- dogsled | ||
- dupl | ||
- gofmt | ||
- goimports | ||
# - gosec | ||
- gosec | ||
- misspell | ||
- nakedret | ||
- stylecheck | ||
# - unconvert | ||
# - unparam | ||
- unconvert | ||
- unparam | ||
- whitespace | ||
disable: | ||
- errcheck | ||
- gosimple | ||
- staticcheck | ||
- ineffassign | ||
- unused | ||
linters-settings: | ||
gosec: | ||
excludes: | ||
# performance issue: see https://github.com/golangci/golangci-lint/issues/4039 | ||
# and https://github.com/securego/gosec/issues/1007 | ||
- G602 | ||
issues: | ||
exclude: | ||
- composites | ||
exclude-rules: | ||
- linters: | ||
- dogsled | ||
text: "declaration has 3 blank identifiers" | ||
path: _test\.go | ||
- linters: | ||
- dupl | ||
path: _test\.go | ||
- linters: | ||
- dupl | ||
- unparam | ||
- gosec | ||
- dogsled | ||
path: _test\.go | ||
|
||
# We need to pass nil Context in order to test DoBare erroring on nil ctx. | ||
- linters: [ staticcheck ] | ||
text: 'SA1012: do not pass a nil Context' | ||
path: _test\.go | ||
|
||
# We need to use sha1 for validating signatures | ||
- linters: [ gosec ] | ||
text: 'G505: Blocklisted import crypto/sha1: weak cryptographic primitive' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# go-github # | ||
|
||
[![go-github release (latest SemVer)](https://img.shields.io/github/v/release/google/go-github?sort=semver)](https://github.com/google/go-github/releases) | ||
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v54/github) | ||
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v55/github) | ||
[![Test Status](https://github.com/google/go-github/workflows/tests/badge.svg)](https://github.com/google/go-github/actions?query=workflow%3Atests) | ||
[![Test Coverage](https://codecov.io/gh/google/go-github/branch/master/graph/badge.svg)](https://codecov.io/gh/google/go-github) | ||
[![Discuss at [email protected]](https://img.shields.io/badge/discuss-go--github%40googlegroups.com-blue.svg)](https://groups.google.com/group/go-github) | ||
|
@@ -24,29 +24,29 @@ If you're interested in using the [GraphQL API v4][], the recommended library is | |
go-github is compatible with modern Go releases in module mode, with Go installed: | ||
|
||
```bash | ||
go get github.com/google/go-github/v54 | ||
go get github.com/google/go-github/v55 | ||
``` | ||
|
||
will resolve and add the package to the current development module, along with its dependencies. | ||
|
||
Alternatively the same can be achieved if you use import in a package: | ||
|
||
```go | ||
import "github.com/google/go-github/v54/github" | ||
import "github.com/google/go-github/v55/github" | ||
``` | ||
|
||
and run `go get` without parameters. | ||
|
||
Finally, to use the top-of-trunk version of this repo, use the following command: | ||
|
||
```bash | ||
go get github.com/google/go-github/v54@master | ||
go get github.com/google/go-github/v55@master | ||
``` | ||
|
||
## Usage ## | ||
|
||
```go | ||
import "github.com/google/go-github/v54/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) | ||
import "github.com/google/go-github/v55/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) | ||
import "github.com/google/go-github/github" // with go modules disabled | ||
``` | ||
|
||
|
@@ -84,36 +84,18 @@ For more sample code snippets, head over to the | |
|
||
### Authentication ### | ||
|
||
The go-github library does not directly handle authentication. Instead, when | ||
creating a new client, pass an `http.Client` that can handle authentication for | ||
you. The easiest and recommended way to do this is using the [oauth2][] | ||
library, but you can always use any other library that provides an | ||
`http.Client`. If you have an OAuth2 access token (for example, a [personal | ||
API token][]), you can use it with the oauth2 library using: | ||
Use the `WithAuthToken` method to configure your client to authenticate using an | ||
OAuth token (for example, a [personal access token][]). This is what is needed | ||
for a majority of use cases aside from GitHub Apps. | ||
|
||
```go | ||
import "golang.org/x/oauth2" | ||
|
||
func main() { | ||
ctx := context.Background() | ||
ts := oauth2.StaticTokenSource( | ||
&oauth2.Token{AccessToken: "... your access token ..."}, | ||
) | ||
tc := oauth2.NewClient(ctx, ts) | ||
|
||
client := github.NewClient(tc) | ||
|
||
// list all repositories for the authenticated user | ||
repos, _, err := client.Repositories.List(ctx, "", nil) | ||
} | ||
client := github.NewClient(nil).WithAuthToken("... your access token ...") | ||
``` | ||
|
||
Note that when using an authenticated Client, all calls made by the client will | ||
include the specified OAuth token. Therefore, authenticated clients should | ||
almost never be shared between different users. | ||
|
||
See the [oauth2 docs][] for complete instructions on using that library. | ||
|
||
For API methods that require HTTP Basic Authentication, use the | ||
[`BasicAuthTransport`](https://godoc.org/github.com/google/go-github/github#BasicAuthTransport). | ||
|
||
|
@@ -135,7 +117,7 @@ import ( | |
"net/http" | ||
|
||
"github.com/bradleyfalzon/ghinstallation/v2" | ||
"github.com/google/go-github/v54/github" | ||
"github.com/google/go-github/v55/github" | ||
) | ||
|
||
func main() { | ||
|
@@ -232,16 +214,9 @@ https://github.com/gregjones/httpcache for that. For example: | |
```go | ||
import "github.com/gregjones/httpcache" | ||
|
||
ts := oauth2.StaticTokenSource( | ||
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, | ||
) | ||
tc := &http.Client{ | ||
Transport: &oauth2.Transport{ | ||
Base: httpcache.NewMemoryCacheTransport(), | ||
Source: ts, | ||
}, | ||
} | ||
client := github.NewClient(tc) | ||
client := github.NewClient( | ||
httpcache.NewMemoryCacheTransport().Client() | ||
).WithAuthToken(os.Getenv("GITHUB_TOKEN")) | ||
``` | ||
|
||
Learn more about GitHub conditional requests at | ||
|
@@ -320,10 +295,8 @@ Furthermore, there are libraries like [cbrgm/githubevents][] that build upon the | |
For complete usage of go-github, see the full [package docs][]. | ||
|
||
[GitHub API v3]: https://docs.github.com/en/rest | ||
[oauth2]: https://github.com/golang/oauth2 | ||
[oauth2 docs]: https://godoc.org/golang.org/x/oauth2 | ||
[personal API token]: https://github.com/blog/1509-personal-api-tokens | ||
[package docs]: https://pkg.go.dev/github.com/google/go-github/v54/github | ||
[personal access token]: https://github.com/blog/1509-personal-api-tokens | ||
[package docs]: https://pkg.go.dev/github.com/google/go-github/v55/github | ||
[GraphQL API v4]: https://developer.github.com/v4/ | ||
[shurcooL/githubv4]: https://github.com/shurcooL/githubv4 | ||
[GitHub webhook events]: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads | ||
|
@@ -396,6 +369,7 @@ Versions prior to 48.2.0 are not listed. | |
|
||
| go-github Version | GitHub v3 API Version | | ||
| ----------------- | --------------------- | | ||
| 55.0.0 | 2022-11-28 | | ||
| 54.0.0 | 2022-11-28 | | ||
| 53.2.0 | 2022-11-28 | | ||
| 53.1.0 | 2022-11-28 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
module github.com/google/go-github/v54/example | ||
module github.com/google/go-github/v55/example | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/bradleyfalzon/ghinstallation/v2 v2.0.4 | ||
github.com/gofri/go-github-ratelimit v1.0.3 | ||
github.com/google/go-github/v54 v54.0.0 | ||
golang.org/x/crypto v0.7.0 | ||
golang.org/x/oauth2 v0.7.0 | ||
github.com/google/go-github/v55 v55.0.0 | ||
golang.org/x/crypto v0.12.0 | ||
golang.org/x/term v0.11.0 | ||
google.golang.org/appengine v1.6.7 | ||
) | ||
|
||
require ( | ||
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect | ||
github.com/cloudflare/circl v1.3.3 // indirect | ||
github.com/golang-jwt/jwt/v4 v4.0.0 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/go-github/v41 v41.0.0 // indirect | ||
github.com/google/go-querystring v1.1.0 // indirect | ||
golang.org/x/net v0.9.0 // indirect | ||
golang.org/x/sys v0.7.0 // indirect | ||
golang.org/x/term v0.7.0 // indirect | ||
golang.org/x/net v0.10.0 // indirect | ||
golang.org/x/sys v0.11.0 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
) | ||
|
||
// Use version at HEAD, not the latest published. | ||
replace github.com/google/go-github/v54 => ../ | ||
replace github.com/google/go-github/v55 => ../ |
Oops, something went wrong.