Standard library / bytes

bytes.NewBufferString()

Creates a buffer containing s as initial unread bytes. Expected stdout: '2 go\n'.

Formal Syntax & Structure

go syntaxgo
func NewBufferString(s string) *Buffer

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.

Return Value

*Buffer

Creates a buffer containing s as initial unread bytes.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  b := bytes.NewBufferString("go")  fmt.Println(b.Len(), b.String())}
Go Reference