// Chapter 15 example: what reader.ReadString really gives you. // Run with: go run exercises/15/05-line-ending.go package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("Type a number: ") text, _ := reader.ReadString('\n') fmt.Printf("%q\n", text) trimmed := strings.TrimSpace(text) fmt.Printf("%q\n", trimmed) withoutTrim, _ := strconv.Atoi(text) withTrim, _ := strconv.Atoi(trimmed) fmt.Println("Without TrimSpace:", withoutTrim) fmt.Println("With TrimSpace:", withTrim) }