-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargChallenge.go
More file actions
37 lines (19 loc) · 799 Bytes
/
argChallenge.go
File metadata and controls
37 lines (19 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Alta3 Research | RZFeeser
Reading positional arguments from the command line*/
package main
import (
"fmt"
"os"
)
func main() {
// os.Args provides access to raw CLI arguments
argsWithProg := os.Args // includes program name
// argsWithoutProg := os.Args[1:] // does not include program name
// arg := os.Args[3] // select the 3rd argument
// remember: the 1st argument is the name
// of the program
// last_arg := os.Args[len(os.Args)-1] // select the last argument // select the last argument
// display the results
fmt.Println("s is the number of ARGS passed:")
fmt.Println(len(argsWithProg))
}