Standard library / io
io.Copy()
Copies until EOF or the first error; successful EOF is not returned as an error. May use WriterTo or ReaderFrom fast paths. Expected stdout: '3 abc <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func Copy(dst Writer, src Reader) (written int64, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| dst | Writer | Destination writer. |
| src | Reader | Source reader. |
Return Value
(written int64, err error)
Copies until EOF or the first error; successful EOF is not returned as an error.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "io" "strings")
func main() { var b bytes.Buffer n, e := io.Copy(&b, strings.NewReader("abc")) fmt.Println(n, b.String(), e)}