package main import ( "bufio" "fmt" "strings" ) func main() { input := "hello world\nthis is a test\n" r := strings.NewReader(input) reader := bufio.NewReader(r) // Read the first line line, _ := reader.ReadBytes('\n') fmt.Printf("Read: %s\n", line) // Read the second line line, _ = reader.ReadBytes('\n') fmt.Printf("Read: %s\n", line) // Try to read a third line, but there isn't one line, err := reader.ReadBytes('\n') fmt.Printf("Read: %s, error: %v\n", line, err) }In this example, we create a string and pass it to a `strings.NewReader`. We then create a bufio Reader around that and use `ReadBytes` to read each line, printing the result. We intentionally try to read a third line, but there isn't one, so we see the error. The package used in this example is bufio.