Created
August 3, 2020 10:59
-
-
Save rfyiamcool/9e182642151316704b81737b6abd8c54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"io/ioutil" | |
) | |
func main() { | |
r := ioutil.NopCloser(bytes.NewReader([]byte("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