适用于Windows和Linux的Go命名管道

Pha*_*aoh 7 named-pipes go

我是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)
Run Code Online (Sandbox Code Playgroud)

任何帮助或指针都会有很大帮助.谢谢

小智 9

根据https://github.com/golang/go/issues/3599

nate的包看起来不错,任何人都可以"去"它.

用纯Go编写的Windows命名管道实现:https:
//github.com/natefinch/npipe

这启发了(Go的Win32 IO相关实用程序):https:
//github.com/Microsoft/go-winio


Ale*_*nok 4

Microsoft 在 Go 中提供了 Windows 命名管道的实现:

https://github.com/Microsoft/go-winio