Reading from standard in Go
Golang takes input from stdin with the Scan
set of functions in the fmt
package. These functions are, Scan
, Scanf
and Scanln
.
var input string
fmt.Scan(&input)
fmt.Println(input)
The above snippet echos the input from stdin to stdout.
Tweet