September 2017
Intermediate to advanced
466 pages
9h 33m
English
Although reading a text file character by character is not needed for the development of the wc(1) utility, it would be good to know how to implement it in Go. The name of the file will be charByChar.go and will be presented in four parts.
The first part is the following Go code:
package main import ( "bufio" "fmt" "io/ioutil" "os" "strings" )
Although charByChar.go does not have many lines of Go code, it needs lots of Go standard packages, which is a naive indication that the task it implements is not trivial. The second part is as follows:
func main() {
arguments := os.Args
if len(arguments) == 1 {
fmt.Println("Not enough arguments!")
os.Exit(1)
}
input := arguments[1]
The third part is the following: ...
Read now
Unlock full access