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/cmd/gomobile: bind fails with interface syntax #27297

Open
forsaken628 opened this issue Aug 28, 2018 · 2 comments

Comments

@forsaken628
Copy link

commented Aug 28, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11 darwin/amd64
gomobile version +bceb7ef Wed Aug 8 22:10:59 2018 +0000 (android,ios); androidSDK=

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/michael/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/michael/Projects/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/bd/rnhtmc553vvcm_ty8nt2tv4c0000gn/T/go-build433537712=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I'm try to build v2ray for ios app.

gomobile bind -target=ios v2ray.com/core

fail:

gomobile: darwin-arm: go build -tags ios -buildmode=c-archive -o /var/folders/bd/rnhtmc553vvcm_ty8nt2tv4c0000gn/T/gomobile-work-288847091/core-arm.a gobind failed: exit status 2
# gobind
/var/folders/bd/rnhtmc553vvcm_ty8nt2tv4c0000gn/T/gomobile-work-288847091/src/gobind/go_coremain.go:1258:9: cannot use (*proxycore_OutboundHandler)(_res_ref) (type *proxycore_OutboundHandler) as type core.OutboundHandler in assignment:
        *proxycore_OutboundHandler does not implement core.OutboundHandler (missing Dispatch method)
/var/folders/bd/rnhtmc553vvcm_ty8nt2tv4c0000gn/T/gomobile-work-288847091/src/gobind/go_coremain.go:1273:9: cannot use (*proxycore_OutboundHandler)(_res_ref) (type *proxycore_OutboundHandler) as type core.OutboundHandler in assignment:
        *proxycore_OutboundHandler does not implement core.OutboundHandler (missing Dispatch method)

a simplified case like this

package hello

//import "context"
//
//type A interface {
//	Run(ctx context.Context)
//}
//
//type BB interface {
//	GetA() A
//}

//------- or -------

type C bool

type A interface {
	AA() C
}

type BB interface {
	AAA() A
}
gomobile bind -target=ios v2ray.com/core/hello

result

gomobile: darwin-arm: go build -tags ios -buildmode=c-archive -o /var/folders/bd/rnhtmc553vvcm_ty8nt2tv4c0000gn/T/gomobile-work-922396824/hello-arm.a gobind failed: exit status 2
# gobind
/var/folders/bd/rnhtmc553vvcm_ty8nt2tv4c0000gn/T/gomobile-work-922396824/src/gobind/go_hellomain.go:55:9: cannot use (*proxyhello_A)(_res_ref) (type *proxyhello_A) as type hello.A in assignment:
        *proxyhello_A does not implement hello.A (missing AA method)

What did you expect to see?

Success build

@gopherbot gopherbot added this to the Unreleased milestone Aug 28, 2018

@gopherbot gopherbot added the mobile label Aug 28, 2018

@xfxdev

This comment has been minimized.

Copy link

commented Mar 6, 2019

same problem:(

@wseternal

This comment has been minimized.

Copy link

commented May 9, 2019

in the interface method signature: AA() C, C (return value type) is not supported by gobind.
use bool directly, instead of define a new type C.

you can add -work parameter to the gobind commandline to keep the temporary workspace contents when error occurred, then check the corresponding .go file and try to search "skip" keyword for detail error information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.