Skip to content

Instantly share code, notes, and snippets.

@pm-kartik-sura
Created June 11, 2015 08:08
Show Gist options
  • Select an option

  • Save pm-kartik-sura/48cf34f02e377c29304e to your computer and use it in GitHub Desktop.

Select an option

Save pm-kartik-sura/48cf34f02e377c29304e to your computer and use it in GitHub Desktop.
read input from console
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
consolereader := bufio.NewReader(os.Stdin)
fmt.Print("Enter your name : ")
input, err := consolereader.ReadString('\n') // this will prompt the user for input
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(input)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment