Every process owns its standard input, output, and error file descriptor. The stdin serves as the input of the process. This recipe describes how to read the data from the stdin.
Reading standard input
How to do it...
- Open the console and create the folder chapter05/recipe01.
- Navigate to the directory.
- Create the fmt.go file with the following content:
package main
import (
"fmt"
)
func main() {
var name string
fmt.Println("What is your name?")
fmt.Scanf("%s\n", &name)
var age int
fmt.Println("What is your age?")
fmt.Scanf("%d\n", &age)
fmt.Printf("Hello %s, your...