Skip to content

adamdrake/gofstream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gofstream

Turn a file into a stream (channel) of lines.

Usage

Simple utility library. Just supply a file path and desired size for the channel buffer and then iterate over the resulting lines on the return channel.

Example

Assume a file somedata.txt contains the desired lines to process.

printf "111\n222\n333\n444\n555\n" > somedata.txt
package main

import (
    "fmt"
    "log"
    "github.com/adamdrake/gofstream"
)

func main() {
    lines, err := fstream.New("somedata.txt", 0)
    if err != nil {
        log.Fatal(err)
    }
    for r := range lines {
        // Do something with each line
        fmt.Println(r)
    }
}

About

Turn a file into a stream (channel) of lines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages