Guest User

Untitled

a guest
Jul 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "time"
  6.  
  7. "github.com/satori/go.uuid"
  8. )
  9.  
  10. func infiniteUuid(prov chan uuid.UUID) {
  11. for {
  12. newg := uuid.NewV4()
  13. prov <- newg
  14. }
  15. }
  16.  
  17. func main() {
  18. prov := make(chan uuid.UUID)
  19.  
  20. go infiniteUuid(prov)
  21.  
  22. for {
  23.  
  24. count := 0
  25. var data uuid.UUID
  26. afterSec := time.After(time.Second)
  27.  
  28. for cont := true; cont; {
  29. select {
  30. case data = <-prov:
  31. count++
  32. case <-afterSec:
  33. fmt.Printf("%d msg/s %s was last\n", count, data)
  34. cont = false
  35. }
  36. }
  37. }
  38. }
Add Comment
Please, Sign In to add comment