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) *BufferParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input 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())}