Skip to content

Instantly share code, notes, and snippets.

@palnabarun
Last active February 3, 2021 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palnabarun/2adc485d3f267ddc882310470751def4 to your computer and use it in GitHub Desktop.
Save palnabarun/2adc485d3f267ddc882310470751def4 to your computer and use it in GitHub Desktop.
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/google/go-github/github"
flag "github.com/spf13/pflag"
)
func main() {
var org string
var repoType string
var entriesPerPage int
flag.StringVarP(&org, "org", "o", "pythonindia", "org to get repos from")
flag.StringVarP(&repoType, "type", "t", "sources", "type of repo")
flag.IntVarP(&entriesPerPage, "n", "n", 100, "org to get repos from")
flag.Parse()
client := github.NewClient(nil)
opt := &github.RepositoryListByOrgOptions{Type: repoType, ListOptions: github.ListOptions{PerPage: entriesPerPage}}
repos, _, err := client.Repositories.ListByOrg(context.Background(), org, opt)
if err != nil {
panic(err)
}
repos_json, err := json.Marshal(repos)
if err != nil {
fmt.Printf("err: %s\n", err)
os.Exit(1)
}
fmt.Println(string(repos_json))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment