Standard library / bufio

bufio.Writer.WriteString()

Writes text and returns bytes accepted, not rune count; final buffered data needs Flush. Expected stdout: '8 سلام <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Writer) WriteString(s string) (int, error)

Parameters & Attributes

NameTypeDescription
sstringText to write.

Return Value

(int, error)

Writes text and returns bytes accepted, not rune count; final buffered data needs Flush.

Working Example

Example Snippetgo
package main
import (  "bufio"  "bytes"  "fmt")
func main() {  var b bytes.Buffer  w := bufio.NewWriter(&b)  n, e := w.WriteString("سلام")  w.Flush()  fmt.Println(n, b.String(), e)}
Go Reference