[Solved] How to extract json api through go to extract stargazers_count of a repo?


Here is an example (completely neglecting error handling):

request, _ := http.Get("https://api.github.com/repos/openebs/openebs")
defer request.Body.Close()
bytes, _ := ioutil.ReadAll(request.Body)

var apiResponse struct {
    StargazersCount int `json:"stargazers_count"`
}
json.Unmarshal(bytes, &apiResponse)

fmt.Println(apiResponse.StargazersCount)

Playground

3

solved How to extract json api through go to extract stargazers_count of a repo?