package main
import (
"fmt"
"os"
)
func main(){
args := os.Args
fmt.Printf("args:%s\n",args)
programName := args[0]
fmt.Printf("The Application's name is %s\n",programName)
otherArgs := args[1:]
for _,name := range otherArgs{
fmt.Printf("Other argments is %s\n",name)
}
}
/* :
cd src/golang/chap01/rec01/
go build -o test
输出
args:[./test hello world john]
The Application's name is ./test
Other argments is hello
Other argments is world
Other argments is john
*/