M
M
Michael2017-05-04 20:14:55
go
Michael, 2017-05-04 20:14:55

Why can't read rss correctly?

Hello. Wrote a small function for reading rss:

type Rss struct {
  Channel Channel `xml:"channel"`
}

func parserRSS(link string) *Rss {
  res, err := http.Get(link)
  if err != nil {
    fmt.Printf("Error: %v\n", err)
  }
  defer res.Body.Close()
  rss := new(Rss)
  decoded := xml.NewDecoder(res.Body)
  err = decoded.Decode(rss)
  if err != nil {
    fmt.Printf("Error: %v\n", err)
  }

  return rss
}

And everything seems to be working, but when I try to call this function once a minute, after a while I see this in the console:
5da10097e52b45c499055e4ca485a027.png
I will clarify that all the necessary packages are connected, and the application does not crash immediately, but after some time.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-05-04
@mak_ufo

well, it writes an error because: connection timed out

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question