我是Go的新手,我想在Golang中创建Named Pipes实现,它适用于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)
任何帮助或指示都会有所帮助。感谢
答案 0 :(得分:8)
根据https://github.com/golang/go/issues/3599
nate的包看起来不错,任何人都可以“去”它。
用纯Go编写的Windows命名管道实现:
https://github.com/natefinch/npipe
这启发了(Go的Win32 IO相关实用程序):
https://github.com/Microsoft/go-winio
答案 1 :(得分:2)
在Microsoft的Go lang中有一个针对Windows的命名管道实现: