From 3a926b35be45b8dc63b682fa5c6f7b4234caf05d Mon Sep 17 00:00:00 2001 From: Thiago Rodrigues Date: Tue, 30 Aug 2016 00:06:35 -0300 Subject: [PATCH] better coding --- remote/bitbucketserver/internal/client.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/remote/bitbucketserver/internal/client.go b/remote/bitbucketserver/internal/client.go index 5dec1896..6a989fab 100644 --- a/remote/bitbucketserver/internal/client.go +++ b/remote/bitbucketserver/internal/client.go @@ -201,23 +201,18 @@ func (c *Client) doDelete(url string) error { func (c *Client) paginatedRepos(start int) ([]*Repo, error) { limit := 1000 requestUrl := fmt.Sprintf(pathRepos, c.base, strconv.Itoa(start), strconv.Itoa(limit)) - log.Debug(fmt.Printf("request :%s", requestUrl)) + log.Debugf("request :%s", requestUrl) response, err := c.client.Get(requestUrl) if err != nil { return nil, err } defer response.Body.Close() - contents, err := ioutil.ReadAll(response.Body) - if err != nil { - return nil, err - } var repoResponse Repos - err = json.Unmarshal(contents, &repoResponse) + err = json.NewDecoder(response.Body).Decode(&repoResponse) if err != nil { return nil, err } - log.Debug(fmt.Printf("repoResponse: %+v\n", repoResponse)) - + log.Debugf("repoResponse: %+v", repoResponse) if(!repoResponse.IsLastPage){ reposList, err := c.paginatedRepos(start + limit); if err != nil {