package main import ( "bufio" "fmt" "os" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("Enter text: ") text, err := reader.ReadString('\n') if err != nil { fmt.Println(err) return } fmt.Println("Input:", text) }
package main import ( "bufio" "fmt" "strings" ) func main() { input := "This is a test string." reader := bufio.NewReader(strings.NewReader(input)) text, err := reader.ReadString('') if err != nil { fmt.Println(err) return } fmt.Println("Input:", text) }Package Library: bufio