Standard library / net/textproto

textproto.Writer.DotWriter()

Write dot-escaped data and normalized CRLF lines. Close to emit the terminating dot line before using the parent writer again. Expected stdout: '"..hello\\r\\n.\\r\\n"\n'.

Formal Syntax & Structure

go syntaxgo
func (w *Writer) DotWriter() io.WriteCloser

Return Value

io.WriteCloser

Writer for dot-framed content; close to finalize.

Working Example

Example Snippetgo
package main
import (  "bufio"  "bytes"  "fmt"  "io"  "net/textproto")
func main() {  var b bytes.Buffer  w := textproto.NewWriter(bufio.NewWriter(&b))  d := w.DotWriter()  must(io.WriteString(d, ".hello\n"))  check(d.Close())  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)  }}
Go Reference