caser/gophernews — pull request #1 by ChimeraCoder (2014-12-24 15:54:30+00:00)
Title: Improve testing, error handling and internal structure

This pull request comprises a few different things that pave the way for some of the features you mention in the README, like rate-limiting. In short:

* Errors are now returned by functions instead of simply logged to the console. This also makes it possible to test more with the unit tests (which all pass, by the way).

* All struct definitions are now automatically generated with `go generate`. This is more idiomatic as of Go 1.4, and is less error-prone. In addition, if the HN API ever changes the format of a struct in the future, updating the struct definitions in this library is now a one-liner: `$ wget && go generate`.

* Item is now an interface, not a struct. This makes the most sense given the way the Item is treated by the HN API.

The good news: all the tests that were previously written pass, and these patches effectively add some more tests to the mix too.

Rate-limiting is actually very easy to add with the [tokenbucket](https://github.com/ChimeraCoder/tokenbucket) library, and this is what we do for [Go's Twitter client library](https://github.com/ChimeraCoder/anaconda/). I figured I'd submit this first and wait and see before adding the rate limiting, but these changes pave the way for adding that later on.