Standard library / io
io.Writer
Accepts bytes and returns the count and error; a short write must return a nonnil error. Implementations must not retain or modify p. Expected stdout: '2 <nil> ok\n'.
Formal Syntax & Structure
go syntaxgo
type Writer interface { Write(p []byte) (n int, err error)}Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "io")
func main() { var b bytes.Buffer var w io.Writer = &b n, e := w.Write([]byte("ok")) fmt.Println(n, e, b.String())}