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
| Name | Type | Description |
|---|---|---|
| s | string | Text 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)}