github.go 519 B

12345678910111213141516171819202122232425
  1. package github
  2. import (
  3. "context"
  4. "github.com/google/go-github/v36/github"
  5. "golang.org/x/oauth2"
  6. )
  7. func GetGithubClient() *github.Client {
  8. ctx := context.Background()
  9. ts := oauth2.StaticTokenSource(
  10. &oauth2.Token{AccessToken: "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"},
  11. )
  12. tc := oauth2.NewClient(ctx, ts)
  13. client := github.NewClient(tc)
  14. return client
  15. // list all repositories for the authenticated user
  16. //repos, _, err := client.Repositories.List(ctx, "", nil)
  17. //fmt.Print(err)
  18. //fmt.Print(repos)
  19. }