August 2019
Beginner to intermediate
798 pages
17h 2m
English
The technique of this section will be illustrated using the Go code of cla.go, which will be presented in three parts. The program will find the minimum and the maximum of its command-line arguments.
The first part of the program is as follows:
package main
import (
"fmt"
"os"
"strconv"
)
What is important here is realizing that getting the command-line arguments requires the use of the os package. Additionally, you need another package, named strconv, in order to be able to convert a command-line argument, which is given as a string, into an arithmetical data type.
The second part of the program is the following:
func main() { if len(os.Args) == 1 { fmt.Println("Please give one or more floats.") os.Exit(1) ...Read now
Unlock full access