go 的命令行参数

package main

import "fmt"
import "os"

func main() {
        var s, sep string

        for i := 1; i < len(os.Args); i++ {
                s += sep + os.Args[i]
                sep = " "
        }

        fmt.Println(s)
}

执行

go run test.go haha heihei

结果: haha heihei

results matching ""

    No results matching ""