Standard library / net/textproto

textproto.Writer

Writes formatted protocol lines and dot-framed blocks using W. Do not allow untrusted newlines in commands. Expected stdout: '"hello\\r\\n"\n'.

Formal Syntax & Structure

go syntaxgo
type Writer struct {  W *bufio.Writer}

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)  }}
Go Reference