How to use FIFO in go

(Helloworld) #1

how to use FIFO in go

(Johan Dahl) #2

Do you mean the data structure or the system call mkfifo?

(FistOfJustice) #3

You would have to implement the queue data structure by yourself. The only data structures available by default are arrays, slices and structs.

(Cecil New) #4

You could implement FIFO using the doubly linked list:

Or adapt one like this:

(Jay Ts) #5

Don’t forget channels. They are a type too.

Channels function as FIFO queues. To quote the Go Programming Language Specification,

Channels act as first-in-first-out queues. For example, if one goroutine sends values on a channel and a second goroutine receives them, the values are received in the order sent.

Depending on the application, a channel can be a very easy way to implement a FIFO.

(Eric Lindblad) #6

FWIW, mkfifo isn’t the same on GNU/Linux and Windows- native.

(Helloworld) #7

mkfifo but It seems that there is no have mkfifo in windwos

(Helloworld) #8

thank you but i want use FIFO to Communication with C# program

(Helloworld) #9

thank you but i want use FIFO to Communication with C# failed

(Helloworld) #10

yes you are right.but how to do it

(Eric Lindblad) #11

Both “Git for Windows” and SUA (32 bit) mkfifo files would be PE32 executables, the latter functioning more like its UNIX antecedent.

SUA was deprecated circa Windows 8.0.

I presume the current “Git for Windows” includes the utility mkfifo.

I encountered problems installing SUA 64 bit on Windows 7 Ultimate.

Not much C# code on the log.

I have not used the VS2017 “Git for Windows” installer, but perhaps the Visual Studio Community Forum might be familiar with Windows-native mkfifo.

(Johan Dahl) #12

If the programs are running at the same time could you use RPC to communicate between them. Something like this:

Or are the programs running at different times and the queue is written by one program and read by the other?

How many items in the queue? How big are they? Maybe if the queue isn’t made of massive amounts of data could you use temporary files which are sorted according to date and always read and then remove the oldest file.

(Johan Dahl) #13

Is a implementation of named pipes in go by microsoft.

(Eric Lindblad) #14

The go-winio file includes a hyperlink for npipe.

(Johan Dahl) #15

Yes but it has not been updated for 4 years so maybe go-winio is a safer bet.