Categorygithub.com/vulpine-io/split-pipe
module
1.1.1
Repository: https://github.com/vulpine-io/split-pipe.git
Documentation: pkg.go.dev

# README

= Split Pipes

image:https://img.shields.io/github/workflow/status/vulpine-io/split-pipe/Go[GitHub Workflow Status, "https://github.com/vulpine-io/split-pipe/actions?query=workflow%3AGo"] image:https://img.shields.io/github/v/tag/vulpine-io/split-pipe?label=version[Latest Tag, link=https://github.com/vulpine-io/split-pipe/tags] image:https://img.shields.io/badge/go-docs-ff69b4["Go Doc", link="https://pkg.go.dev/github.com/vulpine-io/split-pipe"] image:https://goreportcard.com/badge/github.com/vulpine-io/split-pipe["Go Report Card", https://goreportcard.com/report/github.com/vulpine-io/split-pipe] image:https://codecov.io/gh/vulpine-io/split-pipe/branch/master/graph/badge.svg[codecov, https://codecov.io/gh/vulpine-io/split-pipe]

Fork/Join writers and readers.

== Multi-Readers

Multi-readers take input from multiple provided input streams in the order they are provided. When one stream is consumed, the multi-reader will move on to and read from the next until all streams are consumed.

The MultReadCloser type can also be configured to proactively close inputs as soon as they hit EOF.

  • spipe.MultiReader
  • spipe.MultiReadCloser

.MultiReader [source,go]

package main

import ( "fmt" "strings"

"github.com/vulpine-io/split-pipe/v1/pkg/spipe" )

func main() { a := strings.NewReader("hello") b := strings.NewReader("world")

reader := spipe.NewMultiReader(a, b) buffer := make([]byte, 10)

reader.Read(buffer)

fmt.Println(string(buffer)) // helloworld }

== Split-Writers

Split-writers take the written value and write it to all provided writers. The split-writer has a primary writer and secondary writers. The 'written bytes' value returned from writes comes solely from the primary writer. Errors from secondary writers can be optionally ignored.

  • spipe.SplitWriter
  • spipe.SplitWriteCloser

.SplitWriter [source,go]

package main

import ( "fmt" "strings"

"github.com/vulpine-io/split-pipe/v1/pkg/spipe" )

func main() { a := new(strings.Builder) b := new(strings.Builder)

writer := spipe.NewSplitWriter(a, b)

writer.Write([]byte("greetings"))

fmt.Println(a.String()) // greetings fmt.Println(b.String()) // greetings }

# Packages

No description provided by the author