Standard library / bufio

bufio.Writer.WriteByte()

Writes a single byte, flushing the buffer if needed. Check errors and flush before completion. Expected stdout: 'A <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Writer) WriteByte(c byte) error

Parameters & Attributes

NameTypeDescription
cbyteByte or rune to write.

Return Value

error

Writes a single byte, flushing the buffer if needed.

Working Example

Example Snippetgo
package main
import (  "bufio"  "bytes"  "fmt")
func main() {  var b bytes.Buffer  w := bufio.NewWriter(&b)  e := w.WriteByte('A')  w.Flush()  fmt.Println(b.String(), e)}
Go Reference