A simple example
In this subsection, you will learn how to select a particular column from a line of text. To make things more interesting, you will also learn how to read a text file line by line. However, file I/O is the subject of Chapter 8, Telling a UNIX System What to Do, so you should refer to that chapter in order to get more information about the relevant Go code.
The name of the Go source file is selectColumn.go. It will be presented in five segments. The utility needs at least two command-line arguments to operate; the first one is the required column number and the second one is the path of the text file to process. However, you can use as many text files as you want – selectColumn.go will process all of them one by one.
The first ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access