Created
August 30, 2015 07:18
-
-
Save 178inaba/cc536277582390ad9a3f to your computer and use it in GitHub Desktop.
json of github repositories made with go
This file contains hidden or 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
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "github.com/google/go-github/github" | |
| "golang.org/x/oauth2" | |
| ) | |
| func main() { | |
| ts := oauth2.StaticTokenSource( | |
| &oauth2.Token{AccessToken: "... your access token ..."}, | |
| ) | |
| tc := oauth2.NewClient(oauth2.NoContext, ts) | |
| client := github.NewClient(tc) | |
| // list all repositories for the authenticated user | |
| repos, _, err := client.Repositories.List("", nil) | |
| if err != nil { | |
| fmt.Println(err) | |
| } | |
| //fmt.Println(repos) | |
| repoJson, err := json.MarshalIndent(repos, "", "\t") | |
| if err != nil { | |
| fmt.Println(err) | |
| } | |
| fmt.Println(string(repoJson)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment