gomobile bind: missing methods with struct and interface parameters

541 Views Asked by At

I have the following go code:

package hello

import (
    "TestGoMobile/model"
    "fmt"
)

func Test(string) int {
    return 0
}

func Greetings(test model.Test) string {
    return test.Name
}

func Hello(base model.Base) {
    fmt.Println("hello world!")
}
package model

type Test struct {
    Name string
}

type Base interface {
    OnError(errCode int32, errMsg string)
    OnSuccess(data string)
}

when I run: gomobile bind -target=android ./hello

I got the following result:

package hello;

import go.Seq;

public abstract class Hello {
    private Hello() {
    }

    public static void touch() {
    }

    private static native void _init();

    public static native long test(String var0);

    static {
        Seq.touch();
        _init();
    }
}

The methods Greetings and Hello have not been generated successfully.

This seems to be related to the method's struct parameters and interface parameters.

And here is the link to the type restrictions of gomobile, but unfortunately it doesn't help me.

https://pkg.go.dev/golang.org/x/mobile/cmd/gobind#hdr-Type_restrictions

Can you have any idea?

Thanks!

1

There are 1 best solutions below

0
On
// hello.go
// like this...
type Test model.Test
func Greetings(test Test) string {
    return test.Name
}
//...