Standard library / bytes
bytes.Buffer.Next()
Returns up to n next unread bytes and advances the read position. Result aliases storage until the next read or write. Use nonnegative n. Expected stdout: 'go !\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Buffer) Next(n int) []byteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| n | int | Maximum unread byte count to consume; use a nonnegative value. |
Return Value
[]byte
Returns up to n next unread bytes and advances the read position. Result aliases storage until the next read or write. Use nonnegative n.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { b := bytes.NewBufferString("go!") fmt.Println(string(b.Next(2)), b.String())}