x/mobile/cmd/gomobile: update wiki instructions to explicitly set GO111MODULE as needed
gsovereignty opened this issue · 9 comments
The instructions here do not work for me on OSX with 1.12.9:
Gareths-MacBook-Pro-103:~ gareth$ go get golang.org/x/mobile/cmd/gomobile
go: finding golang.org/x/mobile/cmd/gomobile latest
go: finding golang.org/x/mobile/cmd latest
go: finding golang.org/x/mobile latest
Gareths-MacBook-Pro-103:~ gareth$ go get -d golang.org/x/mobile/example/basic
go: finding golang.org/x/mobile/example/basic latest
go: finding golang.org/x/mobile/example latest
go: finding golang.org/x/mobile latest
Gareths-MacBook-Pro-103:~ gareth$ gomobile build -target=android golang.org/x/mobile/example/basic
gomobile: cannot find package "golang.org/x/mobile/example/basic" in any of:
/usr/local/go/src/golang.org/x/mobile/example/basic (from $GOROOT)
/Users/gareth/go/src/golang.org/x/mobile/example/basic (from $GOPATH)
My gopath does not have src/golang.org/x/mobile/example/basic
after this. Should it?
Building with go itself works however and the resulting binary executes successfully:
Gareths-MacBook-Pro-103:~ gareth$ go build golang.org/x/mobile/example/basic
go: finding golang.org/x/mobile/example/basic latest
go: finding golang.org/x/mobile/example latest
go: finding golang.org/x/mobile latest
# golang.org/x/mobile/app
darwin_desktop.m:51:1: warning: method possibly missing a [super prepareOpenGL] call [-Wobjc-missing-super-calls]
My gopath still does not have src/golang.org/x/mobile/example/basic
after this, but it somehow builds successfully.
gomobile init also fails:
Gareths-MacBook-Pro-103:~ gareth$ gomobile init
gomobile: /usr/local/go/bin/go install golang.org/x/mobile/cmd/gobind failed: exit status 1
can't load package: package golang.org/x/mobile/cmd/gobind: cannot find package "golang.org/x/mobile/cmd/gobind" in any of:
/usr/local/go/src/golang.org/x/mobile/cmd/gobind (from $GOROOT)
/Users/gareth/go/src/golang.org/x/mobile/cmd/gobind (from $GOPATH)
Tried getting gobind:
Gareths-MacBook-Pro-103:~ gareth$ go get golang.org/x/mobile/cmd/gobind
go: finding golang.org/x/mobile/cmd/gobind latest
go: finding golang.org/x/mobile/cmd latest
go: finding golang.org/x/mobile latest
Still doesn't work. Tried installing gobind, and now have a gobind binary:
Gareths-MacBook-Pro-103:~ gareth$ gobind
2019/08/25 13:02:43 go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags --]: exit status 1: go: cannot find main module; see 'go help modules'
Still doesn't work.
I'm new to Go and currently fighting very hard with the way it organises things which doesn't seem to make any sense to me (at all) yet, so it's quite likely that I'm simply missing something basic, no idea what though. Any ideas?
My environment for reference:
Gareths-MacBook-Pro-103:~ gareth$ go env
GOARCH="amd64"
GOBIN="/Users/gareth/go/bin"
GOCACHE="/Users/gareth/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/gareth/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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/mn/nbstq9512pb9qx1k6x12ph5w0000gn/T/go-build322501253=/tmp/go-build -gno-record-gcc-switches -fno-common"
Can you list the output for go version
as well as which go
? I am unable to reproduce the build error on my system (same environment), so I would like to make sure that you do not have multiple installations of go on your system. /cc @eliasnaur
Thanks @smasher164, sure:
$ go version
go version go1.12.9 darwin/amd64
$ which go
/usr/local/go/bin/go
$ which gomobile
/Users/gareth/go/bin/gomobile
This is strange though:
$ gomobile version
gomobile version unknown: binary is out of date, re-install it
Rebuilding makes no difference.
Your go get
is running in module mode (as demonstrated by the non-empty GOMOD
variable in go env
). However, the gomobile build
command is running in GOPATH mode (as demonstrated by the error message mentioning GOPATH
in the searched paths).
Hello. Any news or at least workarounds on this? What steps are needed to make gobind workable in this situation?
Hello. Any news or at least workarounds on this? What steps are needed to make gobind workable in this situation?
Specifying GO111MODULE=off
should solve the issue.
GO111MODULE=off go get -d golang.org/x/mobile/example/basic
Updated the wiki page.