milkv duo SDK运行Golang网络程序报错解决方案

前两天想在Milkv duo 256M板子上运行Gin框架的一个小程序,报错无法运行。
报错内容如下:

runtime: epollcreate failed with 38
fatal error: runtime: netpollinit failed

goroutine 1 [running, locked to thread]:
runtime.throw({0x41857b?, 0xa9cb8?})
        /mnt/MyNAS/walker/.bin/go/src/runtime/panic.go:1047 +0x44 fp=0x3fa429f5e8 sp=0x3fa429f5c0 pc=0x4347c
runtime.netpollinit()

其他内容不重要,省略

换成简单的HTTP Server或者Socket代码,也一样报错,内容一致(runtime: epollcreate failed with 38)。在milkv工作人员的热心指导下,得到了大佬的支持,在内核中添加了以下内容,重新编译内核后,Golang的网络程序都可以正常运行了。

CONFIG_FUTEX=y
CONFIG_EPOLL=y

大佬也给出了指导方案的原文链接:Go Wiki: Minimum Requirements - The Go Programming Language

文章重点内容如下:
If you are using tinyconfig (e.g. make tinyconfig) for embedded systems, you will also almost certainly enable printk in the kernel as well as a console; we will not include those generic options here. For Go, you must also enable CONFIG_FUTEX and CONFIG_EPOLL.

可以看出,想要在Linux上运行Golang程序,必须开启内核的printk功能(终端部分使用),以及CONFIG_FUTEX 和 CONFIG_EPOLL必须打开(网络功能)。

希望官方尽快将这两个选项加入默认配置中,避免其他开发者碰到这种错误。