File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed
Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ # github-compare
2+
3+ A Command-line tool to statistics the GitHub repositories
4+
5+ ## Install
6+
7+ ``` bash
8+ $ go install github.com/anqiansong/github-compare
9+ ```
10+
11+ ## Example
12+ ``` bash
13+ $ github-compare zeromicro/go-zero go-kratos/kratos micro/micro go-kit/kit
14+ ```
15+ ![ preview] ( ./resource/compare-preview.png )
16+
17+ ## Usage
18+
19+ ### Preparation
20+ 1 . [ Creating a personal access token] ( https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token )
21+ 2 . Set access token token
22+ - Copied the access token and export to environment
23+ - Or you can set the access token by passing ` github-compare ` argument
24+ ` --token `
25+
26+ ### Execute
27+
28+ ``` bash
29+ # set access token through the flag --token
30+ # github-compare zeromicro/go-zero --token ${accessToken}
31+ # or export access token to environment (recommended)
32+ $ export GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN}
33+ $ github-compare zeromicro/go-zero
34+ ```
35+
36+ ## Note
37+
38+ 1 . A GitHub personal access token is required.
39+ 2 . ` github-compare ` accepts 1 to 4 repositories data queries.
40+ 3 . If you prefer to export the access token to environment, you must use
41+ environment key ` GITHUB_ACCESS_TOKEN `
42+
43+ ## Last
44+ If this repository can help you, give a star please!
45+
46+ Thanks all!
47+
48+ ## License
49+ [ MIT License] ( License )
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ package stat
2727import (
2828 "context"
2929 "fmt"
30+ "log"
3031 "os"
3132 "strings"
3233 "time"
6263
6364func NewStat (repo string , accessToken ... string ) * Stat {
6465 token := getAccessToken (accessToken ... )
66+ if len (token ) == 0 {
67+ log .Fatalln ("missing access token" )
68+ }
6569 ctx := context .Background ()
6670 ts := oauth2 .StaticTokenSource (& oauth2.Token {AccessToken : token })
6771 httpClient := oauth2 .NewClient (ctx , ts )
You can’t perform that action at this time.
0 commit comments