【问题标题】:Named Pipes in Go for both Windows and Linux适用于 Windows 和 Linux 的 Go 中的命名管道
【发布时间】:2016-09-09 08:53:45
【问题描述】:

我是 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)

任何帮助或指示都会有很大帮助。谢谢

【问题讨论】:

    标签: go named-pipes


    【解决方案1】:

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

    nate 的包看起来不错,任何人都可以“去拿”它。

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

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

    【讨论】:

      【解决方案2】:

      Microsoft 的 Go 中有一个用于 Windows 的命名管道实现:

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

      【讨论】:

        猜你喜欢
        • 2013-07-31
        • 2011-04-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-10
        • 2012-01-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多