mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 10:46:39 +00:00
25 lines
411 B
Go
25 lines
411 B
Go
package gh
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/google/go-github/v35/github"
|
|
"golang.org/x/oauth2"
|
|
)
|
|
|
|
func New(ctx context.Context, token string) *github.Client {
|
|
if token == "" {
|
|
token = os.Getenv("GITHUB_TOKEN")
|
|
}
|
|
|
|
if token == "" {
|
|
return github.NewClient(nil)
|
|
}
|
|
|
|
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
|
|
tc := oauth2.NewClient(ctx, ts)
|
|
|
|
return github.NewClient(tc)
|
|
}
|