在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