io.ReadCloser
package main import ( "bytes" // "strings" "fmt" "io/ioutil" ) func main() { r := ioutil.NopCloser(bytes.NewReader([]byte("hello world"))) // r type is io.ReadCloser //r := ioutil.NopCloser(strings.NewReader("hello world")) // example to test r buf := new(bytes.Buffer) buf.ReadFrom(r) r.Close() s := buf.String() fmt.Println(s) }

浙公网安备 33010602011771号