Skip to content

Commit

Permalink
feat: io/ioutil: add MustPrintReader()
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Sep 8, 2024
1 parent 188ce85 commit 09bfdd0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions io/ioutil/ioutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ioutil
import (
"bufio"
"bytes"
"fmt"
"io"
"reflect"
)
Expand All @@ -17,6 +18,14 @@ func IsReader(i any) bool {
return reflect.PointerTo(reflect.TypeOf(i).Elem()).Implements(reader)
}

func MustPrintReader(r io.Reader) {
if b, err := io.ReadAll(r); err != nil {
panic(err)
} else {
fmt.Println(string(b))
}
}

/*
// ReaderToBytes reads from an io.Reader, e.g. io.ReadCloser
func ReaderToBytes(r io.Reader) ([]byte, error) {
Expand Down

0 comments on commit 09bfdd0

Please sign in to comment.