Skip to content

Instantly share code, notes, and snippets.

@178inaba
Created August 30, 2015 07:18
Show Gist options
  • Select an option

  • Save 178inaba/cc536277582390ad9a3f to your computer and use it in GitHub Desktop.

Select an option

Save 178inaba/cc536277582390ad9a3f to your computer and use it in GitHub Desktop.
json of github repositories made with go
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