在Windows中命名为Go的Pipe和Linux [英] Named Pipes in Go for both Windows and Linux

查看:1270
本文介绍了在Windows中命名为Go的Pipe和Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Go的新手,我想在Golang中创建可在Windows和Linux上工作的Named Pipes实现。



我设法让代码在Ubuntu上运行,但这个在Windows上无法使用



Go中没有任何抽象,它允许您在两种环境中使用命名管道

下面是我的一段代码

  //创建管道:不能在windows中运行
syscall.Mkfifo(tmpPipe,0666)

//打开pipe写入
文件,err1:= os.OpenFile(tmpPipe,os.O_RDWR,os .ModeNamedPipe)

//打开管道读取
文件,err:= os.OpenFile(tmpPipe,os.O_RDONLY,os.ModeNamedPipe)

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

解决方案

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


nate的包装外观


使用纯Go编写的Windows命名管道实现:

https://github.com/natefinch/npipe



这受到了启发(Win32的IO相关实用工具):

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


I am new to Go, I want to create Named Pipes implementation in Golang which works on both Windows and Linux.

I managed to get the code working on Ubuntu, but this one does not work on Windows

Isn't there any abstraction in Go which allows you to work with Named Pipes in both environment

Below is piece of my code

//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)

Any help or pointers would help a lot. Thanks

解决方案

According to https://github.com/golang/go/issues/3599

nate's package looks nice, and anyone can "go get" it.

A Windows named pipe implementation written in pure Go:
https://github.com/natefinch/npipe

Which has inspired (Win32 IO-related utilities for Go):
https://github.com/Microsoft/go-winio

这篇关于在Windows中命名为Go的Pipe和Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆