Documentation ¶
Overview ¶
Package fifo implements first-in-first-out objects logic. It gives access to OS-native FIFO objects via:
CreateNamedPipe on windows Mkfifo on unix
Index ¶
Examples ¶
Constants ¶
View Source
const ( // O_NONBLOCK flag makes Fifo open operation nonblocking. O_NONBLOCK = common.O_NONBLOCK )
Variables ¶
This section is empty.
Functions ¶
func DestroyUnixFIFO ¶
DestroyUnixFIFO permanently removes the FIFO.
Types ¶
type Fifo ¶
type Fifo interface { io.ReadWriter io.Closer Destroy() error }
Fifo represents a First-In-First-Out object
Example ¶
testData := []byte{1, 2, 3, 4, 5, 6, 7, 8} go func() { fifo, err := New("fifo", os.O_CREATE|os.O_WRONLY, 0666) if err != nil { panic("new") } defer fifo.Close() if written, err := fifo.Write(testData); err != nil || written != len(testData) { panic("write") } }() buff := make([]byte, len(testData)) fifo, err := New("fifo", os.O_CREATE|os.O_RDONLY, 0666) if err != nil { panic("new") } defer fifo.Close() if read, err := fifo.Read(buff); err != nil || read != len(testData) { panic("read") } // ensure we've received valid data for i, b := range buff { if b != testData[i] { panic("wrong data") } }
Output:
type UnixFifo ¶
type UnixFifo struct {
// contains filtered or unexported fields
}
UnixFifo is a first-in-first-out unix ipc mechanism.
func NewUnixFifo ¶
NewUnixFifo creates a new unix FIFO.
name - object name. flag - flag is a combination of open flags from 'os' package. perm = object permissions.
Click to show internal directories.
Click to hide internal directories.