Issue
So I have been trying to understand what is the real use of these two functions. I only understand the fact that Args gets user input as an slice and the Stdin as a string. So does that mean with Args I can store more values and access them more easily, and with stdin I only get to store at max one input at a time? Can somebody give a simple explanation and practical use of these two function? Thx
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
result := scanner.Text()
fmt.Println(result)
.
arguments := os.Args
fmt.Println(arguments[1:])
Solution
os.Stdin
is the standard input stream, used for piping data from one program to another or for dynamic user input which can be used to make text based user interfaces.
os.Args
are the arguments passed to the program when calling it. ./prog a b "hello world"
would result in ["prog", "a", "b", "hello world"]
. This is also the mechanism used for flags
You can use both at the same time.
Answered By - Dylan Reimerink Answer Checked By - Willingham (WPSolving Volunteer)