September 2017
Intermediate to advanced
466 pages
9h 33m
English
Now that you know how to read a file, it is time to present a modified version of the readColumn.go program you saw in Chapter 3, Advanced Go Features. The new version is also named readColumn.go, but has two major improvements. The first is that you can provide the desired column as a command-line argument and the second is that it can read multiple files if it gets multiple command-line arguments.
The readColumn.go file will be presented in three parts. The first part of readColumn.go is the following:
package main import ( "bufio" "flag" "fmt" "io" "os" "strings" )
The next part of readColumn.go contains the following Go code:
func main() { minusCOL := flag.Int("COL", 1, "Column") flag.Parse() flags ...Read now
Unlock full access