Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package news
  2.  
  3. var (
  4. searchClause chan string
  5. reset chan bool
  6.  
  7. returnClause chan string
  8. result chan []Topic
  9. )
  10.  
  11. func init() {
  12. searchClause = make(chan string)
  13. reset = make(chan bool)
  14.  
  15. returnClause = make(chan string)
  16. result = make(chan []Topic)
  17. }
  18.  
  19. func SearchFor(category string) {
  20. searchClause <- category
  21. }
  22.  
  23. func ResultFor(category string) []Topic {
  24. returnClause <- category
  25. return <-result
  26. }
  27.  
  28. func ResetArchive() {
  29. reset <- true
  30. }
  31.  
  32. func (a Archive) CollectNews() {
  33. for {
  34. select {
  35. case category := <-searchClause:
  36. a.collectNews(category)
  37. case category := <-returnClause:
  38. result <- a.data(category)
  39. case <-reset:
  40. a.resetData()
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement