Command-line arguments are a way to provide the parameters or arguments to the main function of a program. Similarly, In Go, we use this technique to pass the arguments at the run time of a program.
The first argument will be always the program name as shown below.
Example 1: Try to use offline compiler for better results. Save the below file as cmdargs1.go
Output: Here, you can see it is showing the program name with full path. Basically you can call this as Os Filepath output. If you will run the program with some dummy arguments then that will also print as a program name.
Example 2: Save the below file as cmdargs2.go
- How to Read a File Line by Line to String in Golang?
- Function Arguments in Golang
- Golang program that uses func with two arguments
- How to read a file line by line using node.js ?
- Command Line Argument in Scala
- How to execute PHP code using command line ?
- How to execute TypeScript file using command line?
- Connecting to the Internet Using Command Line in Linux
- How to create optional arguments for a SASS mixin?
- Scala | Named Arguments
- How to describe “object” arguments in jsdoc?
- Difference between multiple arguments and options object
- Function Arguments in R Programming
- R - Line Graphs
- How to break line without using <br> tag in HTML / CSS ?
- How to prevent line breaks in the list of items using CSS?
- How to put string in array, split by new line in PHP ?
- CSS | text-decoration-line Property
- How to make a vertical line using HTML ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.