lines

package
v2.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lines splits what is written into whole lines as each one completes, such as the output of a program streamed as it runs, and reads a stream a line at a time

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Next

func Next(r *bufio.Reader, limit int) (line string, long bool, err error)

Reads the next line off the reader as text without its line end, however long the line is. A line of more than limit bytes is read past to its end and comes back empty with long set, so what follows a stream of lines never stops at one and never leaves what writes them waiting on a full pipe. The error is the reader's, io.EOF once the stream ended, and what stood before it with no line end is the line it comes with

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer handing on each whole line written to it without its line end, a line cut across writes held until it completes and bytes that are no text replaced. One writer keeps the rest of one stream, so each stream has its own

func New

func New(emit func(line string)) *Writer

Writer handing each line to emit

func (*Writer) Flush

func (w *Writer) Flush()

Hands on what is left past the last line end as a line of its own, once the stream ended

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

func (*Writer) WriteString

func (w *Writer) WriteString(s string) (int, error)

Writes text, as a stream handing on pieces of text rather than bytes does

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL