// Chapter 15 example: two prompts, two reads. // Run with: go run exercises/15/04-read-two.go package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("First number: ") text, _ := reader.ReadString('\n') a, _ := strconv.Atoi(strings.TrimSpace(text)) fmt.Print("Second number: ") text, _ = reader.ReadString('\n') b, _ := strconv.Atoi(strings.TrimSpace(text)) fmt.Printf("Sum: %d\n", a+b) }