How Do You Read in User Input with Golang?

Problem scenario
You want to read in user input with Golang. What should you do?

This program will illustrate how you accept user input with a Golang program:

package main

import (

func main() {
fmt.Println("Please enter some text:")
reader := bufio.NewReader(os.Stdin)
text, _ := reader.ReadString('\n')
fmt.Println("The text you entered was this: ", text)

Leave a comment

Your email address will not be published. Required fields are marked *