/wrcrux

Add horcruxes to your writer 🧞‍♂️

Primary LanguageGoMIT LicenseMIT

wrcrux

Godoc Report Tests Coverage

Add horcruxes (extension writers) to your writer.

An utility that allows you to pipe one writer to multiple writers (e.g. stdout, a file and a TCP connection). Can perform buffered or unbuffered per message.

All Write calls are queued into a channel that is read in a separate goroutine. Once the channel receives new data it writes the data to all registered outputs.

Installation

go get -u github.com/avrebarra/wrcrux/

Example

wx := wrcrux.New(wrcrux.ConfigWux{})

wx.AddWriter(os.Stdout)
wx.AddWriter(os.Stdout)
wx.AddWriter(os.Stdout)

wx.Write([]byte("data"))
wx.WriteRich(wrcrux.Immediate, []byte("data sync"))
wx.WriteRich(wrcrux.Buffered, []byte("data unbuffered"))