Standard library / net/textproto
textproto.NewReader()
Wrap a buffered reader for line, header and numeric-response parsing. Bound the underlying input for untrusted messages. Expected stdout: 'hello\n'.
Formal Syntax & Structure
go syntaxgo
func NewReader(r *bufio.Reader) *ReaderParameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | *bufio.Reader | Underlying input stream; bound untrusted input before parsing. |
Return Value
*Reader
Reader wrapping the supplied input.
Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "net/textproto" "strings")
func main() { r := textproto.NewReader(bufio.NewReader(strings.NewReader("hello\r\n"))) fmt.Println(must(r.ReadLine()))}
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) }}