Standard library / net/textproto
textproto.NewWriter()
Wrap a buffered writer for line and dot-framed protocol output. Expected stdout: '"hello\\r\\n"\n'.
Formal Syntax & Structure
go syntaxgo
func NewWriter(w *bufio.Writer) *WriterParameters & Attributes
| Name | Type | Description |
|---|---|---|
| w | *bufio.Writer | Underlying destination stream. |
Return Value
*Writer
Writer wrapping the destination.
Working Example
Example Snippetgo
package main
import ( "bufio" "bytes" "fmt" "net/textproto")
func main() { var b bytes.Buffer w := textproto.NewWriter(bufio.NewWriter(&b)) check(w.PrintfLine("%s", "hello")) fmt.Printf("%q\n", b.String())}
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}