cli args
# Node.js
const args = process.argv.slice(2);
console.log(args);
1
2
3
2
3
Output
$ node examples/cli_args.js foo bar qux
[ 'foo', 'bar', 'qux' ]
1
2
2
# Go
package main
import (
"fmt"
"os"
)
func main() {
args := os.Args[1:]
fmt.Println(args)
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Output
$ go run examples/cli_args.go foo bar qux
[foo bar qux]
1
2
2
编辑 (opens new window)
上次更新: 2022/09/30, 11:34:22