September 2017
Intermediate to advanced
466 pages
9h 33m
English
This subsection will present an improved version of the addCLA.go program we developed in the previous chapter, to make it able to handle any kind of user input. The new program will be called addCLAImproved.go, but instead of presenting its full Go code, you will only see the differences between addCLAImproved.go and addCLA.go using the diff(1) command-line utility:
$ diff addCLAImproved.go addCLA.go
13,18c13,14
< temp, err := strconv.Atoi(arguments[i])
< if err == nil {
< sum = sum + temp
< } else {
< fmt.Println("Ignoring", arguments[i])
< }
---
> temp, _ := strconv.Atoi(arguments[i])
> sum = sum + temp
What this output basically tells us is that the last two lines of code, which can be found in addCLA.go ...
Read now
Unlock full access