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

[]byte Parameter Results in Unexpected Integer Type #344

Open
krypton-byte opened this issue Dec 31, 2023 · 1 comment
Open

[]byte Parameter Results in Unexpected Integer Type #344

krypton-byte opened this issue Dec 31, 2023 · 1 comment

Comments

@krypton-byte
Copy link

I am facing an issue with Golang-to-Python interoperability. Specifically, when I call a Python function from Golang and pass a []byte data as a parameter, the Python function unexpectedly receives an integer instead of the intended MengByte/bytes object.

Code:

test.go

package hujan

type MengByte []byte
type Fungsi func(MengByte)

func Test(fun Fungsi) {
    fun(MengByte{255, 211, 21, 23, 0, 1, 2, 3, 82, 2, 33})
}

test.py

from out.hujan import Test, MengByte

def fun(arg: MengByte):
    print('arg: ', type(arg))
    return arg

Test(fun)

I would appreciate assistance in resolving this issue and ensuring that the Python function correctly receives the MengByte/bytes object.

@pratclot
Copy link

pratclot commented Jun 6, 2024

I have the same issue. There are some examples in here, where Python functions are called from Go with arguments. Whenever I try to pass a struct or a map[string]string, Python would receive 1 as argument.

I "worked around" this by passing a string from Go, but it would be nice to learn how to reference Go types in Python.

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

No branches or pull requests

2 participants