rackspace/gophercloud — pull request #133 by jrperritt (2014-02-10 23:26:49+00:00)
Title: list objects in container

This is my take on listing objects in a container (to close #126). A few notes on some of the choices I made:

1) I made an interface called ListOptions to be used for at least this (listing objects) and listing containers; Maybe other things, too. I think this is necessary since most providers will have different options available for listing items. I abstracted out a few parameters that should be available from all providers (specifically, limit, marker, end marker, and format) and used those parameters as the basis for the interface's methods.

2) I use reflection to extract the query parameters from the listOptions structure and create the query string. This seemed a bit unnatural, but I couldn't think of a better way to do it. On the bright side, I'd imagine that bit of code can be extended to cover all the data-types and then used by all providers to create query strings from structure parameters.

2) I chose to use the prefix 'Get' for the interface's methods. Though I acknowledge it isn't idiomatic Go, it was done purposefully to avoid name collisions. For example, a method called "Name()" would not work with OpenStack, since the endpoint's JSON response has a field called "Name".

Feedback encouraged.