Skip to content

Instantly share code, notes, and snippets.

@01x01
Last active February 1, 2019 13:49
Show Gist options
  • Save 01x01/92dbc8a51de3ab9ab91289556ccf85f9 to your computer and use it in GitHub Desktop.
Save 01x01/92dbc8a51de3ab9ab91289556ccf85f9 to your computer and use it in GitHub Desktop.
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