Search Gear #13 – Variable Scoping!

OK so what next?

Need to query ‘my’ twitter timeline every ‘so often’.

‘So often’ is defined by the number of tweets returned from the maximum of 200 as allowed by twitters API. The number of tweets returned defines the period that twitter is queried (not sure if these – every so often – episodes will be this flexible as it may be a cron is required on some server somewhere – maybe just a background process http://stackoverflow.com/questions/12486691/how-do-i-get-my-golang-web-server-to-run-in-the-background).

The query saves each tweet in a file appending new tweets to the file every-time the query occurs. The file is named by date. New contents are appended, new query is based on the next 200 from the last tweet ID retrieved. All of this is saved to file and when a tweet date changes we start a new file based on the date change.

In the future we will extend this so that lists for both people and hastags are also created in the same way.

And we may also want to run these as multiple processes too at some point in the future to cut execution time.

Easy to follow article on structures for package installs
http://phollow.fr/2012/11/building-installing-testing-golang/

Strings, bytes, runes and characters in Go
http://blog.golang.org/strings

Simon Harper ‏@sharpic 1h
More hassle #golang sorry in advance – strange switch problem giving undefined variable http://play.golang.org/p/tnTQPg3jm2 ideas?

THANKS – Damian Gryski ‏@dgryski 1h
@sharpic := scopes to the closest enclosing block, which is this code is the case body. Declare searchResult, err outside and use ‘=’

LESSON for TODAY: you have to be very careful when using the := notation if the scoping it this tight!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s