-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
passing values as a struct #3
Comments
I like this idea, it seems pretty doable and a good fit with Go conventions. |
cool... I'll take a look at this. For what I was doing, I ended up writing a small library that converts structs directly to a Anyway, I mention only to say that there was a fair amount of logic to handle edge cases as well as things like |
Nice: the reflectValue function in your query/encode.go really is thorough. I've had to write code that carried these responsibilities more than once myself, maybe I'll put together a gist. |
I've been toying with the idea of using uritemplates for go-github for a little while now. In particular, I'm interested in trying to clean up some of the code I have for appending query parameters, that currently looks something like:
For small option types this isn't too bad, but gets worse with larger ones and just seems like it could be cleaner. What I've been thinking about is mimicking how
encoding/json
andencoding/xml
use field tags. So something like:Of course, I would ideally just have a single line with a template of
users/{user}/orgs{?page}
, but I haven't decided on the best way to pass the user intoExpand()
yet. I don't want to put it inListOptions
since it's a required parameter to theList()
function and I want that to be explicit.There are of course ways to do this by converting the struct into a map first, and then passing that to
Expand()
, but I figured I'd float this idea to you and see what you thought.The text was updated successfully, but these errors were encountered: