Use os.Stdin to read user input, os.Stdout for normal output, and os.Stderr for error messages.
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
fmt.Print("Enter text: ")
if scanner.Scan() {
fmt.Fprintln(os.Stdout, "You entered:", scanner.Text())
} else if err := scanner.Err(); err != nil {
fmt.Fprintln(os.Stderr, "Error reading input:", err)
}
}