DEV Community

Kassim Damilola A
Kassim Damilola A

Posted on

1 1

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️