Allow multiple tag names#212
Conversation
|
Note that if you checkout a new branch within your GOPATH, make your On Fri, Mar 4, 2016 at 3:26 PM Mal Curtis notifications@github.com wrote:
|
|
@elithrar You mean in the main |
|
My first impressions:
While the type s struct {
Y int `db:"-"`
X int `json:"-"`
}So I'm not sure I'm 100% on board, but I'm willing to be persuaded since you've had more experience with this problem and this particular solution! |
|
I understand your concerns, and it is definitely fitting a specific implementation into the current mapper model. An alternative would be to make a |
Note This PR isn't actually ready for merge since it updates the main package to use my fork
Hey there,
One of the use cases that I have for field names is the idea of generally using the
jsontag, but needing to override it on occasion for data that should be retrieved from the db, but not marshalled to json. By adding multiple tag support toreflectxI can save myself managing two tags.For example, most of our data is encrypted with a per row nonce. We don't want to expose that nonce, but also don't want to expose the nonce via json. By using
jsontags for most fields, but using thedbtag when it's available, I can easily provide this functionality.Does this seem like something you'd like to support? If so we can talk about the implementation - my current one doesn't support multiple tags when using a mapper func - but a setter could be used to adjust or append to the tag names. It just seemed easiest to add a variadic parameter to the
reflectx.Mapperfunction so that the api was backwards compatible.