摘要: ```gotype task struct { fn func() error ret chan error}type tasks struct { ts chan task}func (t *tasks) run() { for { select { case k := <-t.ts: go func(k task) { k.ret <- k.fn() }(k) } }}f... 阅读全文
posted @ 2020-06-09 16:57 白云辉 阅读(710) 评论(0) 推荐(0) 编辑
摘要: golang 接管系统的标准输出https://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html```gonfd, err := syscall.Dup(syscall.Stdout) if err != nil { panic(err) } f, err := os.OpenFile("test.log", os.O_WRON... 阅读全文
posted @ 2020-06-09 15:57 白云辉 阅读(249) 评论(0) 推荐(0) 编辑