How to do it...

These steps cover writing and running your application:

  1. From your terminal/console application, create the chapter9/pipeline directory and navigate to it.
  1. Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter9/pipeline or use this as an exercise to write some of your own code.
  2. Create a file called worker.go with the following content:
        package pipeline        import "context"        // Worker have one role        // that is determined when        // Work is called        type Worker struct {            in chan string            out chan string        }        // Job is a job a worker can do        type Job string        const (            // Print echo's all input to            // stdout            Print Job = "print"            // Encode base64 encodes input            Encode Job = "encode"        ) // Work is how to dispatch a worker, they ...

Get Go Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.