Skip to content
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

otto/value: support conversion to lowerCamel naming #339

Open
robfig opened this issue Feb 18, 2019 · 1 comment
Open

otto/value: support conversion to lowerCamel naming #339

robfig opened this issue Feb 18, 2019 · 1 comment

Comments

@robfig
Copy link

robfig commented Feb 18, 2019

I was interested in exposing Go struct properties and methods to JS code using the conventional casing, lowerCamel.

For example,

type Example struct {
    Name string
}

func (Example) Update(newName string) error {
    // ...
}

Right now this is converted to a JS object with Name and Update properties. One way to allow for customization is to update the value conversion logic to respect otto:"name" struct tags, but that would not help the method names. For that it would need some kind of out-of-band configuration on _runtime, which seems undesirable.

I think my only option right now is to copy the conversion code (runtime.toValue) into my project and then customize it freely.

Does that seem right, or do you have any ideas that I could contribute back?

Thank you!
Rob

@stevenh
Copy link
Collaborator

stevenh commented Nov 29, 2022

A vm creation option to control the ingest of fields and method names seems like the most appropriate option.

For fields you're correct using tags would allow for more customisation but not sure how useful that would be in practice given a top level vm option.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants