-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (42 loc) · 822 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
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
resp, err := http.Get("https://api.github.com/users/NAL-6295")
if err != nil {
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}
data := new(userJson)
if err := json.Unmarshal(b, data); err != nil {
fmt.Println("JSON Unmarshal error:", err)
return
}
repourl := data.ReposURL
reporesp, err := http.Get(repourl)
if err != nil {
return
}
defer reporesp.Body.Close()
repoBytes, err := ioutil.ReadAll(reporesp.Body)
if err != nil {
return
}
repos := new([]user_repos)
if err := json.Unmarshal(repoBytes, repos); err != nil {
return
}
for _, repo := range *repos {
fmt.Println(repo.Name)
fmt.Println(repo.URL)
fmt.Println(repo.Description)
}
}