Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "time"
- "github.com/satori/go.uuid"
- )
- func infiniteUuid(prov chan uuid.UUID) {
- for {
- newg := uuid.NewV4()
- prov <- newg
- }
- }
- func main() {
- prov := make(chan uuid.UUID)
- go infiniteUuid(prov)
- for {
- count := 0
- var data uuid.UUID
- afterSec := time.After(time.Second)
- for cont := true; cont; {
- select {
- case data = <-prov:
- count++
- case <-afterSec:
- fmt.Printf("%d msg/s %s was last\n", count, data)
- cont = false
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment