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)
}
Interactive prompts let your command-line tool ask users for information before running. It works like a cashier asking for your name before processing a payment. You use the bufio package to pause the program, wait for the user to type, and then continue.