Skip to content

Instantly share code, notes, and snippets.

@RicardoLinck
Created May 29, 2020 14:43
Show Gist options
  • Save RicardoLinck/7c84c5d61837ef2e0426e31582e225a6 to your computer and use it in GitHub Desktop.
Save RicardoLinck/7c84c5d61837ef2e0426e31582e225a6 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"time"
"github.com/google/uuid"
)
type inputData struct {
id string
timestamp int64
}
func prepareData(ic <-chan uuid.UUID) <-chan inputData {
oc := make(chan inputData)
go func() {
for id := range ic {
input := inputData{id: id.String(), timestamp: time.Now().UnixNano()}
log.Printf("Data ready for processing: %+v", input)
oc <- input
}
close(oc)
}()
return oc
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment