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

Fix libusb build fail for golang >= 1.24 #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nekoteoj
Copy link
Contributor

Fix for issue #303

Problem:
Go version 1.24 doesn't allow defining a method for non-local structs including created structs with type aliases.

Solution:
The solution is to update the libusb's types from type aliases to type definitions. For example, type Struct_Libusb_Endpoint_Descriptor = C.struct_libusb_endpoint_descriptor is changed to type Struct_Libusb_Endpoint_Descriptor C.struct_libusb_endpoint_descriptor. However, this change prevents the defined types and the C interop types to be used interchangeably without the explicit type casting. As a result, we also needs to explicitly cast the variable types when the go codes interact with c codes. With these changes, I can build the project using go 1.24. It can be built with older go version as well.

I tested this with my Trezor one and it works great. I can use Trezor Suite in the browser and connect the wallet with Metamask.

Edit: I deleted the PR #304 since I think I find a better way to update the lib. Thus, I re-patched the lib again from the master branch. Here is the new refactored version.

Please let me know if you have any suggestions/concerns/comments.

Thank you so much!

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.

1 participant