Standard library / net/textproto
textproto.Reader.ReadLineBytes()
Read one line as bytes without its line ending. Expected stdout: 'hello\n'.
Formal Syntax & Structure
go syntaxgo
func (r *Reader) ReadLineBytes() ([]byte, error)Return Value
([]byte, error)
Line bytes without line ending and error.
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(string(must(r.ReadLineBytes())))}
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) }}