func (t *TechCrunch) Posts(url string) (posts []models.Post) { doc := t.Load(url) channel := make(chan models.Post) s := doc.Find("ul.river li .block-content") for i := range s.Nodes { go func(s *goquery.Selection) { title := s.Find("h2.post-title").Text() url, exists := s.Find("h2.post-title > a").Attr("href") post := models.Post{Title: title, Url: url, Origin: name} if exists { t.Meta(url, &post) } t.debug("%s", post.Json()) channel <- post }(s.Eq(i)) } for { select { case p := <-channel: posts = append(posts, p) t.debug("Length types.Posts: %d", len(posts)) t.debug("Length Nodes: %d", len(s.Nodes)) if len(s.Nodes) == len(posts) { t.spinner.Stop() return posts } case <-time.After(50 * time.Millisecond): t.spinner.Start() } } }