-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(client/windows): introduce go plugin to call fetchResource
as a library
#2263
Conversation
fetchResource
as a libraryfetchResource
as a library
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.
Strong change. I love it!
#include <stdlib.h> // for C.free | ||
|
||
// InvokeGoAPIResult is a struct used to pass result from Go to TypeScript boundary. | ||
typedef struct InvokeGoAPIResult_t |
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.
I think you can define this struct in Go instead and only have the include here.
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.
Do you mean define it as the struct
as:
type InvokeGoAPIResult struct {
Output, ErrorJson *C.char
}
I'm afraid this is not supported by CGo:
Not all Go types can be mapped to C types in a useful way. Go struct types are not supported; use a C struct type. Go array types are not supported; use a C pointer.
This PR introduces a new mechanism for Electron's renderer process to directly call Go functions.
It shows how this works by migrating the
fetchResource
function as an example.