This is my first tutorial in a long series about Go and Android programming. In the limit of my free time, I will try to show you how to do simple applications with the Go programming language (or known as Golang).
You need to install the Go programming language using MSI installer from here.
I set the folder with this path – C:\Go\ but my windows also put some go files under Users folder.
If you want you can to add the Go path into windows environment.
You will have this path in this case: C:\Users\your_account\go\.
The next step is to install the Android NDK from here.
I install the Windows 64-bit into the Users folder. You need to install at C:\Users\your_account\go\.
Because I don’t have a good go programming android example I used the basic default example from golang mobile.
Let’s see the commands to install and used it:
1 2 3 4 | C:\Users\your_account\go\bin>go get golang.org/x/mobile/cmd/gomobile C:\Users\your_account\go\bin>gomobile init -ndk android-ndk-r16b C:\Users\your_account\go\bin>go get -d golang.org/x/mobile/example/basic C:\Users\your_account\go\bin>gomobile build -target=android golang.org/x/mobile/example/basic |
About the gomobile command then the help tells us:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | C:\Users\my_account\go\bin>gomobile.exe Gomobile is a tool for building and running mobile apps written in Go. To install: $ go get golang.org/x/mobile/cmd/gomobile $ gomobile init At least Go 1.7 is required. For detailed instructions, see https://golang.org/wiki/Mobile. Usage: gomobile command [arguments] Commands: bind build a library for Android and iOS build compile android APK and iOS app clean remove object files and cached gomobile files init install mobile compiler toolchain install compile android APK and install on device version print version Use 'gomobile help [command]' for more information about that command. |
If you have the adb command installed on your machine, you can use gomobile command with the argument install to push the APK to your mobile device.
I used Bluestacks emulator for android and the basic example of working well.