win10 golang打包在安卓可执行的文件 2018-11-02

栏目: Go · 发布时间: 6年前

内容简介:参考:
  1. cmd跳转到我们刚写的文件的目录如:test_linux.go

    2.设置在 linux 的运行环境,以下命令在cmd中执行

E:\gogo\main>adb   shell getprop ro.product.cpu.abi #获取安卓手机的cpu信息
arm64-v8a

E:\gogo\main>set GOARCH=arm  

E:\gogo\main>set GOOS=linux

E:\gogo\main>go build -o target-android test_linux.go
  1. 推送文件到安卓上并且adb shell中执行
E:\gogo\main>adb push ./target-android /data/local/tmp  # 推送文件
./target-android: 1 file pushed. 7.7 MB/s (1957989 bytes in 0.244s)

E:\gogo\main>adb shell chmod 777 /data/local/tmp/target-android # 授权 直接777就是这么爽

E:\gogo\main>adb shell
shell@mx5:/ $ cd /data/local/tmp
shell@mx5:/data/local/tmp $ ./target-android  
go runs onlinux
shell@mx5:/data/local/tmp $
//test_linux.go
package main

import (
    "fmt"
    "runtime"
)

func main(){
    fmt.Print("go runs on")
    switch os:=runtime.GOOS;os {
    case "darwin":
        fmt.Println("os x")
    case "linux":
        fmt.Println("linux")
    default:
        fmt.Println("%s.",os)

    }
}

参考: https://blog.csdn.net/lszy24/article/details/78948130


以上所述就是小编给大家介绍的《win10 golang打包在安卓可执行的文件 2018-11-02》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Foundations of PEAR

Foundations of PEAR

Good, Nathan A./ Kent, Allan / Springer-Verlag New York Inc / 2006-11 / $ 50.84

PEAR, the PHP Extension and Application Repository, is a bountiful resource for any PHP developer. Within its confines lie the tools that you need to do your job more quickly and efficiently. You need......一起来看看 《Foundations of PEAR》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

SHA 加密
SHA 加密

SHA 加密工具