September 2017
Intermediate to advanced
466 pages
9h 33m
English
This section will teach you how to modify the contents of a file. The program that will be developed does a pretty convenient job: it adds a line number in front of each line of a text file. This means that you will need to read the input file line by line, keep a variable that will hold the line number value, and save it using the original name. Additionally, the initial value of the variable that holds the line number value can be defined when you start the program. The name of the Go program will be insertLineNumber.go, and it will be presented in four parts.
First, you will see the expected preamble:
package main import ( "flag" "fmt" "io/ioutil" "os" "strings" )
The second part is mainly the configuration of the ...
Read now
Unlock full access