- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter2/pipes.
- Navigate to this directory.
- Run the following command:
Unix pipes are useful when we are passing the output of one program to the input of another. For example, take a look at the following code:
$ echo "test case" | wc -l
1
In a Go application, the left-hand side of the pipe can be read in using os.Stdin, which acts like a file descriptor. To demonstrate this, this recipe will take an input on the left-hand side of a pipe and return a list of words and their number of occurrences. These words will be tokenized on white space.
How to do it...
These steps cover writing and running your application:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter2...