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

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

内容简介:参考:
  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》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

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

Building Web Reputation Systems

Building Web Reputation Systems

Randy Farmer、Bryce Glass / Yahoo Press / 2010 / GBP 31.99

What do Amazon's product reviews, eBay's feedback score system, Slashdot's Karma System, and Xbox Live's Achievements have in common? They're all examples of successful reputation systems that enable ......一起来看看 《Building Web Reputation Systems》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

随机密码生成器
随机密码生成器

多种字符组合密码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具