https://blog.csdn.net/guanchunsheng/article/details/79612153
最简单的例子
package main
import (
"fmt"
"os"
"strconv"
)
func main () {
for idx, args := range os.Args {
fmt.Println("参数" + strconv.Itoa(idx) + ":", args)
}
}
运行结果:
$go run main.go 1 3 -X ?
参数0: /tmp/go-build116558042/command-line-arguments/_obj/exe/main
参数1: 1
参数2: 3
参数3: -X
参数4: ?