export GOROOT="$home/src/go"#go 源码存放位置
export GOBIN="$GOROOT/bin"#go、gofmt、godoc工具位置
export PATH="$GOBIN:$PATH"#
#开始编译,arm架构,linux系统
cd $GOROOT/src
export GOOS=linux#适应的OS
export GOARCH=arm#目标架构
./all.bash
#host comply
cd $GOROOT/src
./all.bash
cat > hello.go <<EOF
package main
import "fmt"func main() {
fmt.Printf("hello,world")
}
EOF
#go build for arm
CGO_ENABLED=O GOOS=linux GOARCH=arm go build -o hello-arm hello.go
#go build for host
go build -o hello-host hello.go
#run on arm、android
adb push hello-arm /data/local/
adb shell
/data/local/hello-arm
有疑问加站长微信联系(非本文作者)