Skip to content

Instantly share code, notes, and snippets.

@vladimirvivien
Created September 13, 2017 00:12
Show Gist options
  • Save vladimirvivien/b1d80b6013de34ff620eb4f2817a07a6 to your computer and use it in GitHub Desktop.
Save vladimirvivien/b1d80b6013de34ff620eb4f2817a07a6 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"io"
"strings"
)
// a simple example of streaming data from a reader.
func main() {
reader := strings.NewReader("Clear is better than clever")
p := make([]byte, 4)
for {
n, err := reader.Read(p)
if err == io.EOF {
break
}
fmt.Println(string(p[:n]))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment