DEV Community

Kassim Damilola A
Kassim Damilola A

Posted on

Passing CLI arguments to excutables with 'go run'

os.Args provides access to raw command-line arguments.

Note that the first value in this slice is the path to the program, and os.Args[1:] holds the arguments to the program.

You can get individual args with normal indexing.

Alt Text

To experiment with command-line arguments run 'go run cli.go parameter-1 parameter 2'

[ parameter-1 parameter 2]

Top comments (0)