Thanks to visit codestin.com
Credit goes to github.com

Skip to content

support internalising structs #1229

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

Merged
merged 3 commits into from
Aug 31, 2023

Conversation

naorzr
Copy link
Contributor

@naorzr naorzr commented Aug 29, 2023

This PR adds code that maps JavaScript object fields to Go struct fields.
Updated the $kindStruct case with a loop to dynamically map JavaScript object fields to corresponding Go struct fields.

Stuff I've tested,

  • simple object to struct conversion
  • an object that is nested within an object
  • exported/none exported fields

possibly fixes #975

@flimzy
Copy link
Member

flimzy commented Aug 30, 2023

I've introduced #1230 which I hope will resolve the build failures, which appear unrelated to these changes.

@flimzy
Copy link
Member

flimzy commented Aug 30, 2023

Thanks for your contribution. I think this could be well improved with the addition of a test (or a few) to demonstrate the new functionality, and that it's working fully as intended.

@naorzr
Copy link
Contributor Author

naorzr commented Aug 30, 2023

@flimzy added some tests, works well.
there's a different issue though, unrelated to this PR, it seems pointer fields, such as *string for example, are causing the function to throw, is this well known?

tests/js_test.go Outdated
Comment on lines 324 to 326
if a.Name != "foo" || a.Age != 952 {
t.Fail()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: please use https://pkg.go.dev/github.com/google/go-cmp/cmp#Diff to do the comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nevkontakte
Copy link
Member

The change looks good to me, save for one minor suggestion.

Thank you for the contribution!

@nevkontakte
Copy link
Member

there's a different issue though, unrelated to this PR, it seems pointer fields, such as *string for example, are causing the function to throw, is this well known?

That description doesn't ring a bell. Would you mind separate issue and providing a reproduction example?

@naorzr
Copy link
Contributor Author

naorzr commented Aug 30, 2023

sure, opened here #1231

@naorzr naorzr requested a review from nevkontakte August 31, 2023 16:38
@nevkontakte nevkontakte merged commit 4859c71 into gopherjs:master Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transpiling junegunns fzf "Cannot internalize utils.Char"
3 participants