ChimeraCoder/anaconda is Twitter API client written with Golang. This library support Twitter Streaming API, Here is a example for using Twitter Streaming API
package main
import(
"github.com/ChimeraCoder/anaconda"
"net/url"
"fmt"
)
func main(){
anaconda.SetConsumerKey(<Consumer Key>)
anaconda.SetConsumerSecret(<Consumer Secret>)
client := anaconda.NewTwitterApi(<Access Token>, <Access Token Secret>)
// Setting parameter using url.Values
v := url.Values{}
v.Set("locations", "<Locations>") // or v.Set("track", "<track>")
s := client.PublicFilterStream(v)
for{
item := <-s.C
switch status := item.(type){
case anaconda.Tweet:
fmt.Println(status.Text)
deafult:
}
}
}
That’s it. It using goroutine, so we can take tweet whenever we like.