Standard library / bytes
bytes.Buffer.Write()
Appends p, returns len(p) and nil error; panics if buffer cannot grow. Expected stdout: '2 <nil> go\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Buffer) Write(p []byte) (n int, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | []byte | Data to append or write. |
Return Value
(n int, err error)
Appends p, returns len(p) and nil error; panics if buffer cannot grow.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { var b bytes.Buffer n, e := b.Write([]byte("go")) fmt.Println(n, e, b.String())}