Golang net/textproto.Writer.DotWriter() function example
package net/textproto
Golang net/textproto.Writer.DotWriter() function usage example
package main
import (
"bufio"
"bytes"
"fmt"
"net/textproto"
)
func main() {
var buf bytes.Buffer
writer := textproto.NewWriter(bufio.NewWriter(&buf))
dot := writer.DotWriter()
defer dot.Close()
n, err := dot.Write([]byte("abc\n.def\n..ghi\n.jkl\n..lmn\n...opq\n."))
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Written %d bytes", n)
}
Output :
Written 34 bytes
Reference :
Advertisement
Something interesting
Tutorials
+9k Golang : Build and compile multiple source files
+16.7k Golang : Gzip file example
+13.3k Golang : Linear algebra and matrix calculation example
+5k Python : Convert(cast) bytes to string example
+10k Golang : Read file and convert content to string
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+16.3k Golang : Find out mime type from bytes in buffer
+19.9k Golang : Count JSON objects and convert to slice/array
+4.9k Nginx and PageSpeed build from source CentOS example
+22.2k Golang : Securing password with salt
+16.1k Golang : How to check if input from os.Args is integer?
+10.6k Golang : Bubble sort example