我是 Go 新手,我想在 Go 中创建命名管道实现,它可以在 Windows 和 Linux 上运行。
我设法让代码在 Ubuntu 上运行,但是这个代码在 Windows 上不起作用
Go 中是否没有任何抽象允许您在两种环境中使用命名管道
下面是我的一段代码
//to create pipe: does not work in windows
syscall.Mkfifo("tmpPipe", 0666)
// to open pipe to write
file, err1 := os.OpenFile("tmpPipe", os.O_RDWR, os.ModeNamedPipe)
//to open pipe to read
file, err := os.OpenFile("tmpPipe", os.O_RDONLY, os.ModeNamedPipe)
任何帮助或指示都会有很大帮助。谢谢
根据https://github.com/golang/go/issues/3599
nate 的包裹看起来不错,任何人都可以“去拿”它。
用纯 Go 编写的 Windows 命名管道实现:
https://github.com/natefinch/npipe
这启发了(Go 的 Win32 IO 相关实用程序):
https://github.com/Microsoft/go-winio
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)