Golang net/textproto.Writer type, PrintfLine() and NewWriter() functions example

package net/textproto

Golang net/textproto.Writer type, PrintfLine() and NewWriter() functions usage example

 package main

 import (
  "bufio"
  "bytes"
  "fmt"
  "net/textproto"
 )

 func main() {

  var buf bytes.Buffer
  writer := textproto.NewWriter(bufio.NewWriter(&buf))

  writer.PrintfLine("The test data size is %d bytes", 1234567)
  fmt.Println(buf.String())

 }

Output :

The test data size is 1234567 bytes

References :

http://golang.org/pkg/net/textproto/#Writer

http://golang.org/pkg/net/textproto/#NewWriter

http://golang.org/pkg/net/textproto/#Writer.PrintfLine

Advertisement