Last active
February 1, 2019 13:49
-
-
Save 01x01/92dbc8a51de3ab9ab91289556ccf85f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment