Documentation ¶
Index ¶
- Constants
- func ChanToBufioWriter(source <-chan string, separator string, bw *bufio.Writer) (err error)
- func ChanToFile(source <-chan string, fileName string) error
- func ChanToFileSize(source <-chan string, bufSize int, fileName string) (err error)
- func ChanToStdout(source <-chan string) error
- func ChanToStdoutSize(source <-chan string, bufSize int) error
- func ChanToWriter(source <-chan string, separator string, w io.Writer) (err error)
- func FileLinesToChan(fileName string, dest chan<- string) error
- func FileToChan(fileName string, split bufio.SplitFunc, dest chan<- string) (err error)
- func ReaderToChan(r io.Reader, split bufio.SplitFunc, dest chan<- string) error
- func ScannerToChan(s *bufio.Scanner, dest chan<- string) error
- func StdinLinesToChan(dest chan<- string) error
- func StdinToChan(split bufio.SplitFunc, dest chan<- string) error
- func StdinWordsToChan(dest chan<- string) error
Examples ¶
Constants ¶
const ( NewLineString = string(0x0A) DefaultBufferSize = 64 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func ChanToBufioWriter ¶
Writes all strings from a channel to a bufio.Writer until the channel is closed. When the channel is empty, the buffer is flushed to the underlying io.Writer and the execution thread is yielded to another goroutine.
func ChanToFile ¶
Writes all strings from a channel to a File, with trailing newline characters, until the channel is closed. Uses the default buffer size.
func ChanToFileSize ¶
Writes all strings from a channel to a File, with trailing newline characters, until the channel is closed. The file will be created if it does not exist, and appended to if it already exists.
func ChanToStdout ¶
Writes all strings from a channel to os.Stdout, with trailing newline characters, until the channel is closed. Uses the default buffer size.
Example ¶
c := make(chan string, 2) go func() { for _, s := range []string{"abcde", "fghij", "klmno", "pqrst"} { c <- s } close(c) }() ChanToStdout(c)
Output: abcde fghij klmno pqrst
func ChanToStdoutSize ¶
Writes all strings from a channel to os.Stdout, with trailing newline characters, until the channel is closed.
func ChanToWriter ¶
Writes all strings from a channel to an io.Writer until the channel is closed. When the channel is empty, the execution thread is yielded to another goroutine.
func FileLinesToChan ¶
Scans all lines from a File into a channel until EOF
func FileToChan ¶
Scans all tokens from a File into a channel until EOF
func ReaderToChan ¶
Scans all tokens from an io.Reader into a channel until EOF
func ScannerToChan ¶
Scans all tokens into a channel until EOF
func StdinLinesToChan ¶
Scans all lines from os.Stdin into a channel until EOF
func StdinToChan ¶
Scans all tokens from os.Stdin into a channel until EOF
func StdinWordsToChan ¶
Scans all words from os.Stdin into a channel until EOF
Types ¶
This section is empty.