I am a go newbie. I am trying to install gomobile for evaluation on MacOS BigSur but can't get past the init step.
running go version returns go version go1.17.6 darwin/amd64
Following the directions, the gomobile install appears to work properly (after explicitly adding gomobile to my PATH), but running init or version fails.
gomobile: go install golang.org/x/mobile/cmd/gobind failed: exit status 1
go install: version is required when current directory is not in a module
Try 'go install golang.org/x/mobile/cmd/gobind@latest' to install the latest version
gomobile version unknown: cannot test gomobile binary: exit status 1, no required module provides package golang.org/x/mobile/cmd/gomobile: go.mod file not found in current directory or any parent directory; see 'go help modules'
I'm guessing this has something to do with environment variables but any suggestions and/or help would be appreciated.
I did manage to finally get
gomobileset up, but the process was painful and the official "experimental" documentation was incomplete and not at all helpful. Here's the steps that worked for me on MacOS (BigSur):Follow steps to install GO from website
Install gomobile
Install Xcode command line tools. If installed but not found, you may need to run the following:
Install Android NDK. This can be done via Android Studio’s Tools->SDK Manager. Need to ensure that the installed version is supported by gomobile since the latest version of the NDK is NOT supported by gomobile.
Update shell to include the following exports:
Create a working directory
Create a module directory
Create a
.gofile in that module directory and give it some content. Note that the package name should be different than the module name or the bind may complain that it can't find anythingFrom the work directory, initialize the module
Install gobind - it will complain that you should be using the
go installmethod instead of thego get(deprecated) but thego installdoes not work (at least for me)Go back into the module directory, initialize and then generate iOS and android code