-
Notifications
You must be signed in to change notification settings - Fork 18
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
customize json tag #15
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request. We’re probably not going to merge it, but I appreciate the PR.
Since there wasn’t a description in the PR, I’m trying to guess at what the purpose is. Why have a separate json_tags
option when tags
can be used to specify the json
tags for a struct field?
Second, the PR renames the package and module from alta
to liov
. All of these would need to be backed out and rebased/squashed before we consider merging this.
Note: you don’t need to rename a a Go module or package to work on a fork of it. You can just use a replace
directive in the go.mod
file to point a module at a local directory or fork:
https://thewebivore.com/using-replace-in-go-mod-to-point-to-your-local-module/
Sorry, I found that the tags option cannot generate custom json tags, so I wrote a json_tag tag myself, and later changed the package name because I think this PR will not be merged for the time being and I want to use it for my own project |
I see. I'd accept a pull request that allows the tags directive to override the |
e0fe946
to
b54f54c
Compare
I think I understand what you mean |
now,the tags directive to override the json tag.But I reset the branch and forced push it, I don’t know if this is a valid PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Now it needs tests!
I think the tags order is not very important |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I’d love to see the new logic extract into a simple helper function that can have its own unit tests, ala:
func mergeTags(tags, newTags string) string {
...
}
6a1ebff
to
1317867
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test rewrites look terrific, thank you!
Hi @liov! Thanks for the updates in the last commit. Would it make sense to import and use this package instead of reimplementing it here? https://pkg.go.dev/github.com/fatih/structtag |
No description provided.