Golang net/textproto.Reader.ReadContinuedLine() and ReadContinuedLineBytes() functions example
package net/textproto
Golang net/textproto.Reader.ReadContinuedLine() function usage example
package main
import (
"bufio"
"bytes"
"fmt"
"net/textproto"
)
func main() {
readbuffer := bytes.NewBuffer([]byte("Line 1 " +
"continued... " +
"Line 2"))
reader := *bufio.NewReader(readbuffer)
tpReader := textproto.NewReader(bufio.NewReader(&reader))
//fmt.Println(&tpReader)
str, err := tpReader.ReadContinuedLine()
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Whole line : ", str)
//------------------------------------
readbuffer2 := bytes.NewBuffer([]byte("Line 1 " +
"continued... " +
"Line 2"))
reader2 := *bufio.NewReader(readbuffer2)
tpReader2 := textproto.NewReader(bufio.NewReader(&reader2))
strByte, err := tpReader2.ReadContinuedLineBytes()
if err != nil {
fmt.Println(err)
return
}
fmt.Println("In []byte format : ", string(strByte[:]))
}
Output :
Whole line : Line 1 continued... Line 2
In []byte format : Line 1 continued... Line 2
References :
http://golang.org/pkg/net/textproto/#Reader.ReadContinuedLine
http://golang.org/pkg/net/textproto/#Reader.ReadContinuedLineBytes
Advertisement
Something interesting
Tutorials
+14.2k Golang : Fix image: unknown format error
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+29.5k Golang : How to create new XML file ?
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+11.9k Golang : Convert(cast) bigint to string
+6.3k Golang : How to get capacity of a slice or array?
+36.3k Golang : Convert(cast) int64 to string
+7.5k Golang : Rename part of filename
+17k Golang : Capture stdout of a child process and act according to the result
+16.3k Golang :Trim white spaces from a string