@@ -34,11 +34,18 @@ type ReposInfoJson struct {
3434 Stargazers_count int `json:"stargazers_count"`
3535}
3636
37- type ReposInfoJsonArray []ReposInfoJson
38-
3937type userCollection struct {
40- accountInfo Userinfo
41- repoInfo ReposInfoJsonArray
38+ AccountInfo struct {
39+ Login string `json:"login"`
40+ Html_url string `json:"html_url"`
41+ Name string `json:"name"`
42+ Email string `json:"email"`
43+ Bio string `json:"bio"`
44+ Public_repos int `json:"public_repos"`
45+ Followers int `json:"followers"`
46+ Following int `json:"following"`
47+ }
48+ Repositories []ReposInfoJson
4249}
4350
4451func responseToUserData (data []byte ) Userinfo {
@@ -47,8 +54,8 @@ func responseToUserData(data []byte) Userinfo {
4754 return userData
4855}
4956
50- func responseToRepoData (data []byte ) ReposInfoJsonArray {
51- var reposData ReposInfoJsonArray
57+ func responseToRepoData (data []byte ) [] ReposInfoJson {
58+ var reposData [] ReposInfoJson
5259 _ = json .Unmarshal (data , & reposData )
5360 return reposData
5461}
@@ -82,10 +89,10 @@ func GetUserData(username string) Userinfo {
8289 return searchResult
8390}
8491
85- func GetReposData (username string , noOfRepos int ) ReposInfoJsonArray {
92+ func GetReposData (username string , noOfRepos int ) [] ReposInfoJson {
8693
8794 var bodyJson []byte
88- var result ReposInfoJsonArray
95+ var result [] ReposInfoJson
8996
9097 for i := 1 ; i <= ((noOfRepos / 100 ) + 1 ); i ++ {
9198
@@ -122,12 +129,10 @@ func Fetch(username string) userCollection {
122129 accountData := GetUserData (username )
123130 repoData := GetReposData (username , accountData .Public_repos )
124131
125- return (userCollection {accountInfo : accountData , repoInfo : repoData })
132+ return (userCollection {accountData , repoData })
126133}
127134
128135func MarshalFetchData (data userCollection ) []byte {
129- accountByte , _ := json .MarshalIndent (data .accountInfo , " " , " " )
130- reposByte , _ := json .MarshalIndent (data .repoInfo , " " , " " )
131- resultByte := append (accountByte , reposByte ... )
132- return resultByte
136+ accountByte , _ := json .MarshalIndent (data , " " , " " )
137+ return accountByte
133138}
0 commit comments