-
Notifications
You must be signed in to change notification settings - Fork 172
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
Support alternative struct tags (instead of url
)
#29
Comments
Is this still a problem for you, or did you end up working around it? If it's still a desirable feature, does anyone have pointers to examples of other libraries that do this? #15 does provide an implementation, but I just don't think I've ever seen a library that allows customizing struct tags like this, so would love to see any prior art before making any decisions. |
There IS such kind of scenarios. We now have two:
type config struct {
Username string `sys1:"username" sys2:"loginname"`
} However, I prefer passing tag as a runtime parameter instead of pre-binding. Such as: v, _ := query.ValuesByTag(&conf, "sys1") |
Hey @willnorris , we need this feature too, we are are working with |
We have the same use case that would be great to solve using this library. |
We also have a similar use case where we need to form encode a struct that only contains |
gorilla/schema implements this in exactly the same way using SetAliasTag both in encoder and decoder. |
We use Gin, and we're looking at using this library. Gin provides a
BindQuery
method, which decodes query params from a request into a struct, so long as the incoming request matches the expected names, expressed via the struct tagform
.We'd like to be able to use the same struct tags for encoding and decoding. In order to do so, we'd like to be able to configure this library to reflect on a different struct tag during encoding. In our case, we'd like to be able to configure this library to use the same struct tag as Gin, i.e., the
form
tag.Would you be open to a PR that implements configurable struct tags?
I'm not sure what the best mechanism would be, perhaps a build flag or ENV_VAR. Any suggestions here would be most welcome.
The text was updated successfully, but these errors were encountered: