Skip to content

Commit

Permalink
Fix bug with dead items
Browse files Browse the repository at this point in the history
  • Loading branch information
alexferrari88 committed Oct 23, 2022
1 parent 33228c1 commit a27c448
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/gohn/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ Package GoHN is a wrapper for the Hacker News API: https://github.com/HackerNews
package gohn

const (
Version = "0.7.2"
Version = "0.7.3"
)
12 changes: 9 additions & 3 deletions pkg/gohn/items.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ func (s *ItemsService) FetchAllDescendants(ctx context.Context, item *Item, fn I
}

// initialize kidsQueue so that the fetching in the for loop can start
for _, kid := range *item.Kids {
kidsQueue <- kid
}
go func() {
for _, kid := range *item.Kids {
kidsQueue <- kid
}
}()

// goroutine to close the done channel when all the items are fetched and processed
go func() {
Expand Down Expand Up @@ -159,6 +161,10 @@ L:
return
}
}
if it.Dead != nil && *it.Dead {
wg.Done()
return
}
commentsChan <- it
}()
// add the item to the map and, if it has any kid,
Expand Down

0 comments on commit a27c448

Please sign in to comment.