google / google/go-querystring

Support alternative struct tags (instead of `url`)

Open
#29 6 comments 10 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.1k
Forks
188
Avg merge
10h 23m
Merged PRs (30d)
1

Description

We use [Gin](https://github.com/gin-gonic/gin), and we're looking at using this library. Gin provides [a `BindQuery` method](https://github.com/gin-gonic/gin/blob/08b52e5394099db4c2399357e060619c1545083e/context.go#L575), which decodes query params from a request into a struct, so long as the incoming request matches the expected names, expressed via the struct tag `form`.

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.