cli args


Node.js

  1. const args = process.argv.slice(2)
  2. console.log(args)

Output

  1. $ node examples/cli_args.js foo bar qux
  2. [ 'foo', 'bar', 'qux' ]

Go

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. )
  6. func main() {
  7. args := os.Args[1:]
  8. fmt.Println(args)
  9. }

Output

  1. $ go run examples/cli_args.go foo bar qux
  2. [foo bar qux]