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

查看所有标签

猜你喜欢:

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

Stylin' with CSS

Stylin' with CSS

Wyke-Smith, Charles / 2012-10 / $ 50.84

In this completely revised edition of his bestselling Stylin' with CSS, veteran designer and programmer Charles Wyke-Smith guides you through a comprehensive overview of designing Web pages with CSS, ......一起来看看 《Stylin' with CSS》 这本书的介绍吧!

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

多种字符组合密码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具