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 · 3 comments
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@libnat
Copy link

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 Android, iOS, and x/mobile label Jun 21, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 21, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 24, 2020
@cagedmantis
Copy link
Contributor

/cc @hyangah

@paulaolmedo
Copy link

paulaolmedo commented Mar 29, 2021

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

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.

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

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.

any news from this issue? the same happens to me with go1.16.1 - darwin/amd64 aaand with go1.16.2 - linux/amd64

@zwz-coding
Copy link

I have the same issue for android platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants