Standard library / net/textproto
textproto.Reader.DotReader()
Decode dot-stuffed data, normalize CRLF to LF and stop at the dot terminator. Valid only until the next Reader method call. Expected stdout: '".hello\\nworld\\n"\n'.
Formal Syntax & Structure
go syntaxgo
func (r *Reader) DotReader() io.ReaderReturn Value
io.Reader
Reader for decoded dot-framed content.
Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "io" "net/textproto" "strings")
func main() { r := textproto.NewReader(bufio.NewReader(strings.NewReader("..hello\r\nworld\r\n.\r\n"))) fmt.Printf("%q\n", string(must(io.ReadAll(r.DotReader()))))}
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) }}