gpt4 book ai didi

go - Windows 和 Linux 中的命名管道

转载 作者:IT王子 更新时间:2023-10-29 01:12:50 26 4
gpt4 key购买 nike

我是 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's package looks nice, and anyone can "go get" it.

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

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

关于go - Windows 和 Linux 中的命名管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39407592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com