command-line arguments _ golang

Command-line arguments are a common way to parameterize execution of programs. For example, go run hello.go uses run and hello.go arguments to the go program

package main

import (
    "fmt"
    "os"
)

func main() {

    argsWithProg := os.Args
    argsWithoutProg := os.Args[1:]

    arg := os.Args[3]

    fmt.Println(argsWithProg)
    fmt.Println(argsWithoutProg)
    fmt.Println(arg)
}
[./commonLineArgument a b c d]
[a b c d]
c

总结 : 

  1 : ....

posted on 2015-03-31 13:22  xjk112  阅读(726)  评论(0编辑  收藏  举报