Skip to content

Instantly share code, notes, and snippets.

@rfyiamcool
Created August 3, 2020 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfyiamcool/9706f8b92cde8125b3d6272d0133652c to your computer and use it in GitHub Desktop.
Save rfyiamcool/9706f8b92cde8125b3d6272d0133652c to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"strings"
"fmt"
"io/ioutil"
)
func main() {
r := ioutil.NopCloser(strings.NewReader("hello world")) // r type is io.ReadCloser
// example to test r
buf := new(bytes.Buffer)
buf.ReadFrom(r)
r.Close()
s := buf.String()
fmt.Println(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment