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

x/mobile: function with alias type as argument or return value cannot be exported #39735

Open
libnat opened this issue Jun 21, 2020 · 1 comment
Open

Comments

@libnat
Copy link

@libnat libnat commented Jun 21, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.4 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOOS="darwin"

What did you do?

  1. Create a demo pkg at ~/go/src/demo
  2. Add ~/go/src/demo/model/model.go
    package model
    type IntSet struct {
    }
    
  3. Add ~/go/src/demo/demo.go
    package demo
    import "demo/model"
    type IntSet = model.IntSet
    func NewIntSet() *IntSet {
        return new(IntSet)
    } 
    
  4. Generate bindings
    gomobile bind -target=ios demo

What did you expect to see?

Generate bindings:

@class DemoIntSet;
@interface DemoIntSet ... 
...
FOUNDATION_EXPORT DemoIntSet* _Nullable DemoNewIntSet(void);

What did you see instead?

@class DemoIntSet;
@interface DemoIntSet ... 
...
// skipped function NewIntSet with unsupported parameter or return types

I guess gobind doesn't use demo.IntSet as demo.NewIntSet's return value type, still use model.IntSet which is not exported.
To fix this issue, I have to define a new type like type IntSet model.IntSet, in this way, it requires to rewrite all methods because now demo.IntSet is a new type. This brings lots of work.

@gopherbot gopherbot added the mobile label Jun 21, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 21, 2020
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Jun 24, 2020

/cc @hyangah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.