package main
import (
"fmt"
"os"
)
func main() {
args := os.Args
// all command line args
println(args)
// The first argument, zero item from array,
// is the name of the called binary.
programName := args[0]
fmt.Printf("The binary name is: %s
", programName)
// by omiting the first argument.
otherArgs := args[1:]
fmt.Println(otherArgs)
for idx, arg := range otherArgs {
fmt.Printf("Arg %d = %s
", idx, arg)
}
}
/*
[5/5]0xc42000e140
The binary name is: ./go_web
[fdsf fdsaf dsafdsfkf 1234]
Arg 0 = fdsf
Arg 1 = fdsaf
Arg 2 = dsafdsfkf
Arg 3 = 1234
*/