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]
 parameter-1

Top comments (0)

12 Gorgeous UI Components for Your Design Inspiration

>> Check out this classic DEV post <<