How to Create Interactive Prompts in a Go CLI

Cli
Create interactive Go CLI prompts by reading user input with bufio.NewReader and os.Stdin.

Use the bufio package to read user input line-by-line and prompt for responses in a loop.

package main

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

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