PROGRAM
OUTPUT
$ go build cmd_args.go
$ ./cmd_args fi1 sec2 thr3
Number of Arguments : 4
All Args except program : [fi1 sec2 thr3]
First Argument : fi1
Second Argument : sec2
Third Argument : thr3
package main
import (
"fmt"
"os"
)
func main() {
all_args := os.Args
fmt.Println("Number of Arguments :", len(all_args))
fmt.Println("All Args except program :", all_args[1:])
fmt.Println("First Argument :", all_args[1])
fmt.Println("Second Argument :", all_args[2])
fmt.Println("Third Argument :", all_args[3])
}
OUTPUT
$ go build cmd_args.go
$ ./cmd_args fi1 sec2 thr3
Number of Arguments : 4
All Args except program : [fi1 sec2 thr3]
First Argument : fi1
Second Argument : sec2
Third Argument : thr3
No comments:
Post a Comment