I have the next code:
resp, err := http.Get("https://www.google.com")
if err != nil{
panic(err)
}
r := bufio.NewReader(resp.Body)
for v, e := r.ReadString('
'); e == nil; {
fmt.Println(v)
}
So, I want to read responce body in loop but reader r
reads first line of Body
infinitely.
While in the same time, this code works fine:
v, e := r.ReadString('
')
for e == nil {
fmt.Println(v)
v, e = r.ReadString('
')
}
Can someone explain why the first solution has such behaviour?