Skip to content

Instantly share code, notes, and snippets.

@cideM
Last active May 19, 2022 09:53
Show Gist options
  • Save cideM/b2c52e61112f7f45d53f2ec03718b8ab to your computer and use it in GitHub Desktop.
Save cideM/b2c52e61112f7f45d53f2ec03718b8ab to your computer and use it in GitHub Desktop.
The new main function with generics
func main() {
source := []string{"FOO", "BAR", "BAX"}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
readStream, err := producer(ctx, source)
if err != nil {
log.Fatal(err)
}
step1results, step1errors := step(ctx, readStream, transformA)
step2results, step2errors := step(ctx, step1results, transformB)
allErrors := Merge(ctx, step1errors, step2errors)
sink(ctx, cancel, step2results, allErrors)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment