用 go 开发 app

draft: false date: 2018-03-17 11:51:06 cover: https://res.cloudinary.com/teepublic/image/private/s--lJGaW4VN--/c_crop,x_10,y_10/c_fit,w_776/c_crop,g_north_west,h_1100,w_554,x_111,y_-27/l_upload:v1452885561:production:blanks:gawvl5gka1pqwssxidw5/fl_layer_apply,g_north_west,x_-361,y_-104/b_rgb:ffffff/c_limit,f_jpg,h_630,q_90,w_630/v1504358109/production/designs/1867887_1.jpg tags: - bigzhu preview:


基础环境

https://github.com/golang/mobile

go get golang.org/x/mobile/cmd/gomobile
gomobile init

报了个错

gomobile: go install -pkgdir=/Users/bigzhu/go/pkg/gomobile/pkg_darwin_arm std failed: exit status 2
# runtime/cgo
exec: "2018-03-17": executable file not found in $PATH

再执行一次就好了, 囧

尝试编译一个例子

gomobile build -target=android golang.org/x/mobile/example/basic

下载 ndk

解压后放到 ~ 目录

重新 init

gomobile init -ndk ~/android-ndk-r16b/

再尝试编译

gomobile build -target=android golang.org/x/mobile/example/basic

usb 插入手机

gomobile install golang.org/x/mobile/example/basic

因为没有安装 adb 所以报错了

下载 platform-tools

加入 fish 中

set PATH $HOME/platform-tools $PATH

官方有这么一些 example, 可以装了看看 https://godoc.org/golang.org/x/mobile/example

框架

https://gomatcha.io/

Matcha is a package for building iOS and Android applications and frameworks in Go.

看上去还是不错的