我在下面抨擊了這個 Go twitter 客戶端,客戶端在顯示結果方面仍然需要一些工作,我想將 JSON 結果http://pastie.org/7298856表示為 Go 結構,我不不需要 JSON 結果中的所有字段,任何指針?package mainimport ( "fmt" "io/ioutil" "log" "net/http")type TwitterResult struct{}var twitterUrl = "http://search.twitter.com/search.json?q=%23KOT"func retrieveTweets(c chan<- string) { for { resp, err := http.Get(twitterUrl) if err != nil { log.Fatal(err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) c <- string(body) }}func displayTweets(c chan string) { fmt.Println(<-c)}func main() { c := make(chan string) go retrieveTweets(c) for { displayTweets(c) }}
- 2 回答
- 0 關注
- 214 瀏覽
添加回答
舉報
0/150
提交
取消