Standard library
Buffered lines
Split text or files into lines.
Introduction
Split text or files into lines. Import std/bufio to bind the module as bufio. Call free functions as bufio.name(...). Struct methods use a receiver value.
/ std/bufio
This page is the package reference for std/bufio. Private helpers used only by co-located tests are not listed.
Functions
Free functions on bufio. Each function has a short description, an example, then parameters and return shape.
lines
Splits text into lines on newline characters. Call form: bufio.lines(s).
/ std/bufio
$ lines = bufio.lines("a\nb\n")Parameters: s: text to split. Returns: List of line strings without trailing newlines.
read_lines
Reads a file and splits it into lines. Call form: bufio.read_lines(path).
/ std/bufio
$ lines = bufio.read_lines(p'/tmp/lines.txt')
Parameters: path: file path as string or locator. Returns: List of line strings from the file.