shad-go/lectures/10-io/limitreader/main.go

18 lines
234 B
Go
Raw Normal View History

2020-04-23 01:40:13 +00:00
package main
import (
"io"
"log"
"os"
"strings"
)
func main() {
r := strings.NewReader("some io.Reader stream to be read\n")
lr := io.LimitReader(r, 4)
if _, err := io.Copy(os.Stdout, lr); err != nil {
log.Fatal(err)
}
}