Created
October 24, 2013 17:15
-
-
Save ameyms/7141289 to your computer and use it in GitHub Desktop.
Alternative go-github API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
watchers, pager, _, err := client.Activity.ListWatchers("o", "r") | |
if pager.HasNext() { | |
watchers, pager, _, err = pager.Next() | |
} | |
//.. | |
//or: | |
watchers, pager, _, err = pager.Last() | |
} |
Drats. Its times like these that I feel really really stupid.
I clearly didn't think this through and wasted your time as well.
Although I would blame excessive usage of dynamically typed languages for this stupid suggestion :P
Thanks for your time! And thanks for merging the PR!
No worries... it's not stupid at all. I'm still getting used to working in Go myself... some things really are different here than how you would approach them in other languages (particularly dynamically typed languages, as you mention).
And to be clear, I have no problem with adding something to the library that makes working with paginated results a little easier. I just honestly don't know what else we can do than what we currently have.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
okay, but what does
func (i *Iterator) Data()
return? What I'm getting at, is that I suspect the only thing that would really work is to returninterface{}
, which requires that the user then type switch to whatever the real type is and you lose all type safety.One alternative would be to have a new Iterator type for every data type you need to page through, so that
Data()
can return an exact type rather thaniterator{}
, but now you've close to doubled the number of types that users of the library have to contend with.