在openwrt上跑golang程序

1. 安装Go语言、搭建开发环境
https://blog.csdn.net/qq_38105536/article/details/142635132

2. VMware Workstation部署最新版OpenWrt 23.05.3
https://blog.csdn.net/gtj0617/article/details/137706312

桥接模式(负责物理网络连接状态),设置ip:192.168.0.11

设置root密码
root@OpenWrt:~# passwd

停止防火墙服务:
/etc/init.d/firewall stop

禁用防火墙在启动时自动启动:
/etc/init.d/firewall disable

文件传输协议:SCP

3. Go 语言交叉编译在 openwrt 上运行的程序

chmod 777 gohello

root@OpenWrt:/mnt# ./gohello
Go Hello 11!

 

真实设备:在window上编译Go代码在 openwrt 上运行

root@OpenWrt:~# uname -m
armv7l

cmd
set GOOS=linux&& set GOARCH=arm&& set GOARM=7&& go build


BusyBox v1.33.2 (2024-09-24 01:36:06 UTC) built-in shell (ash)

_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 21.02-SNAPSHOT, r0-b68c233
-----------------------------------------------------
OW21.02_EC200A_CNAA_rls988_1.057.067_20241021_01_09
-----------------------------------------------------
root@OpenWrt:~# uname -m
armv7l
root@OpenWrt:~# cd /mnt/
root@OpenWrt:/mnt# chmod 777 test
root@OpenWrt:/mnt# ./test
Go Hello 11!

 

解压指令

tar -xvf filename.tar

posted @   CHHC  阅读(209)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示