使用Go并行读取多个URL

huangapple go评论109阅读模式
英文:

Reading many URLs in parallel using Go

问题

我对Go语言非常陌生。我有一个任务:

读取10个(例如)URL:
"http://... file.xml"
"http://... file2.xml"
...
等等。

它们必须并行读取。然后由函数进行处理。
如果URL的响应时间太长 - 必须忽略它(例如1秒后)。

谢谢!

英文:

I'm very new to Go-language. And I have a task:

Read 10 (for example) urls:
"http://... file.xml"
"http://... file2.xml"
...
and so on.

They must be read in parallel. And then processed by function.
If URL's response takes too long - it must be ignored. (For example after 1 second).

Thank you!

答案1

得分: 1

元回答:仔细阅读http://golang.org/doc上的所有内容,并特别关注“Go并发模式”。

英文:

Meta answer: Work through all the stuff on http://golang.org/doc and have a special look at "Go Concurrency Patterns".

huangapple
  • 本文由 发表于 2013年6月6日 01:03:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/16945813.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定