mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:55:28 +08:00
23 lines
393 B
Go
23 lines
393 B
Go
// read input from the console:
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"bufio"
|
|
"os"
|
|
)
|
|
|
|
var inputReader *bufio.Reader
|
|
var input string
|
|
var err error
|
|
|
|
func main() {
|
|
inputReader = bufio.NewReader(os.Stdin) // reader for input
|
|
fmt.Println("Please enter some input: ")
|
|
input, err = inputReader.ReadString('\n')
|
|
|
|
if err == nil {
|
|
fmt.Printf("The input was: %s\n", input)
|
|
}
|
|
}
|