Standard library / strings
strings.Builder.Write()
Appends bytes as-is, returning their count and nil error; does not validate UTF-8. Expected stdout: '2 <nil> go\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Builder) Write(p []byte) (int, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| p | []byte | Data to append or write. |
Return Value
(int, error)
Appends bytes as-is, returning their count and nil error; does not validate UTF-8.
Working Example
Example Snippetgo
package main
import ( "fmt" "strings")
func main() { var b strings.Builder n, e := b.Write([]byte("go")) fmt.Println(n, e, b.String())}