-
-
Save r00tvvm/fc5ee2d3413a21f1de7c4a5ae1af4ca8 to your computer and use it in GitHub Desktop.
Golang stdin read line example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bufio" | |
| "fmt" | |
| "os" | |
| ) | |
| func main() { | |
| reader := bufio.NewReader(os.Stdin) | |
| fmt.Print("Enter name: ") | |
| text, err := reader.ReadString('\n') | |
| if err != nil { | |
| panic(err) | |
| } | |
| fmt.Printf("Your name is: %s\n", text) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment