Go – How to Read a User-Input in Go Programming Language

Hello everyone, In this post, we will show you how to read the user-input in the Go programming language. The example program has been tested and shared in the same post.

Go – Reading the User-Input

package main
import (
// main function
func main() {
reader := bufio.NewReader(os.Stdin)
fmt.Println("What is your name?")
name, _ := reader.ReadString('\n')
fmt.Println("Hello", name)


What is your name?
Dinesh Krishnan
Hello Dinesh Krishnan


  1. https://golang.org/doc/
  2. https://golang.org/pkg/
  3. https://golang.org/pkg/fmt/
  4. https://golang.org/pkg/fmt/#Println
  5. https://golang.org/pkg/bufio/
  6. https://golang.org/pkg/bufio/#NewReader
  7. https://golang.org/pkg/bufio/#Reader.ReadString
  8. https://golang.org/pkg/os/


No Responses

Leave a Reply

Your email address will not be published.