-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (46 loc) · 972 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"Gemini-D/fetch-github-stars/format"
"Gemini-D/fetch-github-stars/repo"
"encoding/json"
"fmt"
"github.com/joho/godotenv"
"io"
"net/http"
"os"
)
func main() {
godotenv.Load()
token := os.Getenv("TOKEN")
var list []*repo.Repo
var repos = []string{
"hyperf/hyperf",
"easy-swoole/easyswoole",
"swoft-cloud/swoft",
"laravel/laravel",
"Yurunsoft/imi",
"hyperf/nano",
"hyperf/hyperf-docker",
"hyperf/hyperf-skeleton",
}
if len(os.Args) > 1 {
repos = os.Args[1:]
}
for _, v := range repos {
request, _ := http.NewRequest("GET", "https://api.github.com/repos/"+v, nil)
request.Header.Set("Authorization", "Token "+token)
response, err := (&http.Client{}).Do(request)
if err != nil {
continue
}
body, _ := io.ReadAll(response.Body)
repo := new(repo.Repo)
err = json.Unmarshal(body, repo)
if err != nil {
fmt.Print(err)
continue
}
list = append(list, repo)
}
format.PrintTable(list)
}