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: imported structs from other packages get skipped even if they're valid #39791

Closed
ToJen opened this issue Jun 23, 2020 · 2 comments
Closed
Labels
FrozenDueToAge 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

@ToJen
Copy link

ToJen commented Jun 23, 2020

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

$ go version
go version go1.13.10 darwin/amd64

Does this issue reproduce with the latest release?

Yeah

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/user/Library/Caches/go-build"
GOENV="/Users/user/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/user/go"
GOPRIVATE=""
GOPROXY="..."
GOROOT="/usr/local/Cellar/go@1.13/1.13.10_1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go@1.13/1.13.10_1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/user/Documents/project/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/..../T/go-build123=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Trying to run gomobile bind -target=ios github.com/user/a on this code and it won't work even though MyStruct is valid against the type restrictions.

Folder structure

/a
|_ main.go
|_ /b
    |_ models.go
// in a/b/models.go

package b

type MyStruct struct {
  Value string
}

//////////

// in a/main.go

package a

import "github.com/user/a/b"

func NewIssue() (*b.MyStruct, error) {
 // ...
}

However the following work:

  • if I change the return type of NewIssue() to (string, error) for example; or
  • if I move MyStruct from folder a/b to a

What did you expect to see?

The generated header files containing definitions for my function.

What did you see instead?

// Objective-C API for talking to github.com/user/a Go package.
//   gobind -lang=objc github.com/user/a
//
// File is generated by gobind. Do not edit.

#ifndef __Issue_H__
#define __Issue_H__

@import Foundation;
#include "ref.h"
#include "Universe.objc.h"


// skipped function NewIssue with unsupported parameter or return types

#endif
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jun 23, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 23, 2020
@cagedmantis cagedmantis changed the title x/mobile: Imported structs from other packages get skipped even if they're valid x/mobile: imported structs from other packages get skipped even if they're valid Jun 24, 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

@ToJen
Copy link
Author

ToJen commented Jun 25, 2020

I think this may have to do with how I used gomobile bind. I now know I can use gomobile bind -target=ios pkg1 pkg2 pkg3 so it'll pick up the package that has MyStruct and compile it.

@ToJen ToJen closed this as completed Jun 25, 2020
@golang golang locked and limited conversation to collaborators Jun 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

3 participants