Documentation ¶
Overview ¶
Package flexiwriter - Like io.MultiWriter, but with removable writers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is like io.MultiWriter, but with dynamic addition and removal of writers. Writer's are safe to be called concurrently from multiple goroutines.
func New ¶
New returns a new Writer, ready for use. Any writers passed to new will be added to the returned Writer as if pased to Add with a nil onremove.
func (*Writer) Add ¶
Add adds a new writer to fw. On removal, onremove wil be called in a separate goroutine if not nil and passed any error which caused the removal. If onremove was called as a result of calling fw.Remove, onremove will be passed nil. If w has already been added to fw, w's existing onremove will set to the onremove passed to Add. Adding a nil io.Writer is a no-op.
func (*Writer) Remove ¶
Remove removes a writer from fw. If the writer was added with a non-nil onremove function, it will be called and passed nil. If w isn't in fw, as can happen if the writer is removed by fw.Write, Remove is a no-op. Remove returns true if w was in fw.
func (*Writer) Write ¶
Write satisfies io.Writer. If any of fw's writers returns an error, its onremove function is called and it is removed. The size of p and nil are returned. Write blocks until all of the underlying writes have finished.
func (*Writer) WriteString ¶
WriteString is a convenience wrapper around fw.Write which writes s.