Skip to content

Commit

Permalink
Merge pull request googlecodelabs#339 from cassierecher/removebuilder
Browse files Browse the repository at this point in the history
Remove strings.Builder usage from fetch.go.
  • Loading branch information
cassierecher authored Aug 8, 2019
2 parents 9404116 + d947dd9 commit 47e8905
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions claat/fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ func (f *Fetcher) SlurpImages(src, dir string, steps []*types.Step) (map[string]
}

imap := make(map[string]string, count)
errBuilder := strings.Builder{}
var errStr string
for i := 0; i < count; i++ {
r := <-ch
imap[r.file] = r.url
if r.err != nil {
errBuilder.WriteString(fmt.Sprintf("%s => %s: %v\n", r.url, r.file, r.err))
errStr += fmt.Sprintf("%s => %s: %v\n", r.url, r.file, r.err)
}
}
if errBuilder.Len() > 0 {
return nil, errors.New(errBuilder.String())
if len(errStr) > 0 {
return nil, errors.New(errStr)
}

return imap, nil
Expand Down

0 comments on commit 47e8905

Please sign in to comment.