Standard library / io
io.ReaderFrom
Optional bulk transfer interface that reads from a Reader until EOF or error; io.Copy may dispatch to it. Expected stdout: '2 ok <nil>\n'.
Formal Syntax & Structure
go syntaxgo
type ReaderFrom interface { ReadFrom(r Reader) (n int64, err error)}Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "io" "strings")
func main() { var b bytes.Buffer var rf io.ReaderFrom = &b n, e := rf.ReadFrom(strings.NewReader("ok")) fmt.Println(n, b.String(), e)}