go 交叉编译扩展 ac68u 梅林固件, go 依赖 zoneinfo 的解决问题

CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build ddns.go

r8500 虽然是 ARMv7 , 但应该是被阉割过,不支持 ARMv7 的一些特性,只能采用 GOARM = 5 , 6/7都不行, 编译后才能运行

另外,编译的文件,由于应用到时区,会报错:

error: panic: open /usr/local/go/lib/time/zoneinfo.zip: no such file or directory

在其源码内可找到问题:

https://golang.org/src/time/zoneinfo_unix.go#L31

// Many systems use /usr/share/zoneinfo, Solaris 2 has
// /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ.
var zoneSources = []string{
    "/usr/share/zoneinfo/",
    "/usr/share/lib/zoneinfo/",
    "/usr/lib/locale/TZ/",
    runtime.GOROOT() + "/lib/time/zoneinfo.zip",
}

解决方法: go 源码包内,找到 lib/time/zoneinfo.zip 复制到运行环境的  $GOROOT/lib/time/ 内。 运行前指定 GOROOT

GOROOT=/jffs/scripts /jffs/scripts/ddns -rr bx1 -rid 123456 -value $1

猜你喜欢

转载自www.cnblogs.com/zhenfei/p/10284417.html