go arm、android版本

来源:互联网 发布:淘宝卖家货到付款拒签 编辑:程序博客网 时间:2024/05/16 16:18

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

0 0
原创粉丝点击