Standard library / bytes

bytes.Buffer.String()

Returns unread bytes as a string; a nil receiver returns the text <nil>. Expected stdout: 'o\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Buffer) String() string

Return Value

string

Returns unread bytes as a string; a nil receiver returns the text <nil>.

Working Example

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