September 2017
Intermediate to advanced
466 pages
9h 33m
English
The flag package does the dirty work of parsing command-line arguments and options for us; so, there is no need for writing complicated and perplexing Go code. Additionally, it supports various types of parameters, including strings, integers, and Boolean, which saves you time as you do not have to perform any data type conversions.
The usingFlag.go program illustrates the use of the flag Go package and will be presented in three parts. The first part has the following Go code:
package main import ( "flag" "fmt" )
The second part, which has the most important Go code of the program, is as follows:
func main() { minusO := flag.Bool("o", false, "o") minusC := flag.Bool("c", false, "c") minusK := flag.Int("k", 0, "an int") ...Read now
Unlock full access