Skip to content

Commit cb0eb93

Browse files
committed
add license
1 parent fbcd6a8 commit cb0eb93

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

parse.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import (
1212
"time"
1313
)
1414

15+
type License struct {
16+
SpdxID string `json:"spdx_id"`
17+
}
18+
1519
func main() {
1620
tsvFile, _ := os.Create("data.tsv")
1721
defer tsvFile.Close()
@@ -32,7 +36,7 @@ func main() {
3236
repos = append(repos, repo)
3337
}
3438
sort.Sort(ByStars(repos))
35-
header := []string{"stars", "language", "updated", "issues", "size", "forks", "watchers", "repo", "created", "description"}
39+
header := []string{"stars", "language", "updated", "issues", "size", "forks", "watchers", "license", "repo", "created", "description"}
3640
writer.Write(header)
3741
for _, repo := range repos {
3842
url := repo.Url
@@ -44,8 +48,12 @@ func main() {
4448
watchers := strconv.Itoa(repo.Watchers)
4549
pushedAt := repo.PushedAt.Format("2006-01-02")
4650
createdAt := repo.CreatedAt.Format("2006-01-02")
51+
license := ""
52+
if repo.License != nil {
53+
license = repo.License.SpdxID
54+
}
4755
desc := repo.Desc
48-
values := []string{stars, lang, pushedAt, openIssues, size, forks, watchers, url, createdAt, desc}
56+
values := []string{stars, lang, pushedAt, openIssues, size, forks, watchers, license, url, createdAt, desc}
4957
writer.Write(values)
5058
}
5159
}
@@ -60,6 +68,7 @@ type Repo struct {
6068
Watchers int `json:"watchers_count"`
6169
PushedAt time.Time `json:"pushed_at"`
6270
CreatedAt time.Time `json:"created_at"`
71+
License *License `json:"license"`
6372
Desc string `json:"description"`
6473
}
6574

0 commit comments

Comments
 (0)