Standard library / bufio

bufio.ScanLines()

Default scanner split; removes newline and optional preceding carriage return. Delivers a final nonempty unterminated line. Expected stdout: '4 ab <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error)

Parameters & Attributes

NameTypeDescription
data[]byteInput bytes or destination storage, according to operation.
atEOFboolWhether the source has reached end of input.

Return Value

(advance int, token []byte, err error)

Default scanner split; removes newline and optional preceding carriage return.

Working Example

Example Snippetgo
package main
import (  "bufio"  "fmt")
func main() { a, t, e := bufio.ScanLines([]byte("ab\r\ncd"), false); fmt.Println(a, string(t), e) }
Go Reference