-
Notifications
You must be signed in to change notification settings - Fork 48
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
Attempted fix for same func and var names #42
base: master
Are you sure you want to change the base?
Conversation
Is it possible to only give each file unique Header and Footer names, to avoid same func and var names? |
I'm sorry, would you please elaborate your idea? Thanks! |
I was wondering whether it is possible to not have the skip defaults flag
and still avoid the name conflicts, by only renaming the HeaderaFilename
and FooterFilename to be unique for each file in the folder?
…On Mon, 19 Mar 2018, 09:28 MSalopek, ***@***.***> wrote:
I'm sorry, would you please elaborate your idea? Thanks!
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#42 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvsLYw_-eOr01pxgSe8G-LIEOjj3n7zks5tf2xCgaJpZM4Sqauj>
.
|
It is possible, yes. But the name |
@@ -100,6 +101,15 @@ func (p *html) generateFormFunc(servName string, method *descriptor.MethodDescri | |||
</div>` | |||
p.P(`var Form`, servName, "_", generator.CamelCase(method.GetName()), " string = `", s, "`") | |||
} | |||
func processFileName (inStr string) string { | |||
reg, err := regexp.Compile("[^a-zA-Z0-9]+") |
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.
regexp.MustCompile and then it could rather be done as part of init or a var.
var alphaNum = regexp.MustCompile("[^a-zA-Z0-9]+")
s := strings.TrimSuffix(inStr, ".proto") | ||
processed := strings.Replace(strings.Title(reg.ReplaceAllString(s," ")), " ", "", -1) | ||
return processed | ||
} | ||
|
||
func (p *html) Generate(file *generator.FileDescriptor) { |
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.
Technically the html struct has state.
So it can remember to only generate some things once itself per package, without using a flag.
What do you think about that proposal?
Sorry for pushing this, but I want to try and keep things as simple as possible.
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.
Then we also don't need custom HeaderFooterName
This should enable the user to choose whether or not they want all code to be generated or just the code that returns a map of all available methods -> by using the flag "skip-defaults".
Also, Headers and Footers get renamed: HeaderFileName and FooterFileName so every file would have different header and footer names.
Please review.