Golang flag.Arg() function examples

package flag

Arg returns the i'th command-line argument. Arg(0) is the first remaining argument after flags have been processed.

Golang flag.Arg() function usage examples

Example 1:

 flag.Parse()
 dbconnection, err := ConnectToDB(flag.Arg(0))

Example 2:

 socketconnection := flag.Agr(1)
 portnumber := flag.Arg(2)

Reference :

http://golang.org/pkg/flag/#Arg

Advertisement