O'Reilly logo

Go Programming Blueprints - Second Edition by Mat Ryer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading votes from Twitter

In your $GOPATH/src folder, alongside other projects, create a new folder called socialpoll for this chapter. This folder won't be a Go package or a program by itself, but it will contain our three component programs. Inside socialpoll, create a new folder called twittervotes and add the obligatory main.go template (this is important as main packages without a main function won't compile):

package main 
func main(){} 

Our twittervotes program is going to:

  • Load all polls from the MongoDB database using mgo and collect all options from the options array in each document
  • Open and maintain a connection to Twitter's streaming APIs looking for any mention of the options
  • Figure out which option is mentioned and push that option through ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required