Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Read line from stdin (keyboard)

Read from the stdin (standard input) Get input from the keyboard in golang

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Print("Enter Your name: ")
	name, _ := reader.ReadString('\n')
	fmt.Println("Hello", name)
}