September 2017
Intermediate to advanced
466 pages
9h 33m
English
In this section, we will develop a program that adds all the values of a given column of text with multiple lines. To make things even more interesting, the column number will be given as a parameter in the program. The main difference between the program of this subsection and readColumn.go from the previous subsection is that you will need to convert each value into an integer number.
The name of the program that will be developed is summary.go and can be divided into three parts.
The first part is this:
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
func main() {
var s [3]string
s[0] = "1 b 3"
s[1] = "11 a 1 14 1 1"
s[2] = "-1 2 -3 -4 -5"
The second part has the following Go code:
arguments := os.Args column, ...
Read now
Unlock full access