Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Command Line User Input in Golang
// Command Line User Input in Golang
// REFERENCE: https://stackoverflow.com/questions/20895552/how-to-read-from-standard-input-in-the-console
package main
import (
"fmt"
"bufio"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
fmt.Print(">>> ")
userInput, _ := reader.ReadString('\n')
fmt.Println(userInput)
fmt.Print(">>> ")
userInput2, _ := reader.ReadString('\n')
fmt.Println(userInput2)
fmt.Print(">>> ")
userInput3, _ := reader.ReadString('\n')
fmt.Println(userInput3)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.