// Gather stargazers of GitHub repository
Gather stargazers of GitHub repository
// Gather stargazers of GitHub repository
func (d *Data) Gather() (*Data, error) {
	if len(d.Button) > 0 {
		d.URL = d.Button[0]
		d.Button = make([]string, 0)
		if strings.Contains(d.URL, "before") {
			d.End = true
			return d, nil
		}
	} else {
		d.URL += "/stargazers"
	}
	req, err := d.get(d.URL)
	if err != nil {
		return d, err
	}
	resp, err := client.Do(req)
	if err != nil {
		return d, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return d, fmt.Errorf("error code %d", resp.StatusCode)
	}
	if err := goq.NewDecoder(resp.Body).Decode(&d); err != nil {
		return d, err
	}
	if len(d.Button) == 2 {
		d.Button = d.Button[1:]
		d.End = false
	}
	return d, nil
}
func ( d * Data ) Gather ( ) ( * Data , error ) { if len ( d . Button ) > 0 { d . URL = d . Button [ 0 ] d . Button = make ( [ ] string , 0 ) if strings . Contains ( d . URL , " " ) { d . End = true return d , nil } } else { d . URL += " " } req , err := d . get ( d . URL ) if err != nil { return d , err } resp , err := client . Do ( req ) if err != nil { return d , err } defer resp . Body . Close ( ) if resp . StatusCode != http . StatusOK { return d , fmt . Errorf ( " " , resp . StatusCode ) } if err := goq . NewDecoder ( resp . Body ) . Decode ( & d ) ; err != nil { return d , err } if len ( d . Button ) == 2 { d . Button = d . Button [ 1 : ] d . End = false } return d , nil }
Gather stargazers of GitHub repository
Gather stargazers of GitHub repository