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

calling golang function which takes an argument a slice with Perl #8

Open
b03cmans opened this issue Jun 25, 2020 · 1 comment
Open
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@b03cmans
Copy link

i am trying to call the below golang func from the documention that you provided on Metacpan

//export Sort
func Sort(vals []int) { sort.Ints(vals) }

any idea how i can attach it like the other functions on the example ?

@plicease plicease added enhancement New feature or request help wanted Extra attention is needed labels Jun 28, 2020
@plicease
Copy link
Member

Go slice looks like this in C:

typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;

To be able to use this we'd have to implement something similar to FFI::Go::String, except for slices. Since the data is stored in a void * rather than a specific type it should be parameterized, so that we can use specific types. The int part from []int for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

2 participants