Description
Go version
go1.22.4 linux/amd64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/opt/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/opt/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/go_dist/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/go_dist/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/mobiletest/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2991625483=/tmp/go-build -gno-record-gcc-switches'
What did you do?
Using a dummy main.go:
main.go
package mobiletest
func Foo() {
}
go install golang.org/x/mobile/cmd/gomobile@latest
gomobile init
go mod init mobiletest
go mod vendor
gomobile bind -a -target android .
go get golang.org/x/mobile/bind
What did you see happen?
The above fails with:
"golang.org/x/mobile/bind" is not found; run go get golang.org/x/mobile/bind: no Go package in golang.org/x/mobile/bind
As a workaround, before Go1.22, one could install mobile/bind to $GOPATH
and use gomobile bind
without modules to side-step this issue completely:
GO111MODULE=off go get -u golang.org/x/mobile/cmd/gomobile
GO111MODULE=off gomobile bind -a -target android .
Since GO 1.22 however, go get
is not allowed anymore outside of modules.
What did you expect to see?
No error running gomobile bind
.
gomobile bind
seems to be unworkable using Go 1.22 when a vendor folder is present. The only workaround seems to be to delete the vendor
folder before using gomobile bind
.
Related: #34181, but the GO111MODULE=off
workaround does not work anymore as of Go 1.22.
Activity
gabyhelp commentedon Jun 11, 2024
Similar Issues
gomobile init
Go 1.17 #50994(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
benma commentedon Jun 11, 2024
Another thing I tried is #43736 (comment):
Import
_ "golang.org/x/mobile/cmd/gobind"
, thengo mod vendor
.But then
gomobile bind
seems to invokego mod tidy
on a package that is not module aware and results in:[-]x/mobile: does not work with Go 1.22 if a vendor module is present, even with the `GO111MODULE=off` workaround[/-][+]x/mobile: does not work with Go 1.22 if a vendor folder is present, even with the `GO111MODULE=off` workaround[/+]hyangah commentedon Jun 12, 2024
Can you try to manually list the golang.org/x/mobild/bind/* packages in an ignored file, and run
go mod tidy & go mod vendor
, so the necessary dependencies are vendored if vendoring is required?Keeping up with all the Go, Android, Apple toolchains changes is a non-trivial task. Unfortunately, there is nobody actively working on x/mobile as of today.
benma commentedon Jun 25, 2024
Thanks for the suggestion.
I tried this. Here is the go.mod file:
These are all the files:
(mobilex.go is the file with the dummy imports you suggested).
Running (using Go 1.22.4)
results in
This is unfortunate indeed. We heavily rely on gomobile and it has been a huge success for us so far. See also this post of appreciation.
Paging a person who recently committed to x/mobile: @hajimehoshi - maybe you also have some suggestions for how to fix this? I'd be happy to contribute, but I am afraid I am a bit out of my depth.
baizon commentedon Jul 21, 2024
Hi,
The issue is, that
go list
is running without-mod=mod
.I've added a go list args logic that gives the possibility to add flags and resolves the issue (see golang/mobile#105)
My test:
feat: added glflags
4 remaining items