Skip to content

Instantly share code, notes, and snippets.

@mastern2k3
Created July 18, 2018 13:28
Show Gist options
  • Save mastern2k3/42e66a7b6c14a3edd950fc218959157b to your computer and use it in GitHub Desktop.
Save mastern2k3/42e66a7b6c14a3edd950fc218959157b to your computer and use it in GitHub Desktop.
Tester program for a channel and a cosumer
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
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment