Args hold the command-line arguments, starting with the program name.
var Args []string
package main
import (
"fmt"
"os"
)
func main() {
args := os.Args
// This call will print
// all command line arguments.
fmt.Println(args)
}
package main
import (
"fmt"
"os"
)
func main() {
args := os.Args
// The first argument args[0], zero item from slice
// is the name of the program
fmt.Printf("The Program Name is: %s \n", args[0])
}
package main
import (
"fmt"
"os"
)
func main() {
args := os.Args
/* for i := 0; i < len(args); i++ {
fmt.Println(args[i])
} */
// same as above but using for _,_ := range []slice
for _, value := range args {
fmt.Println(value)
}
}