textfile

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 5 Imported by: 0 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 textfile reads a text file as the file function of expressions and the file action do, and splits text into its lines.

Index

Constants

This section is empty.

Variables

View Source
var ErrChanged = errors.New("changed while it was opened")

ErrChanged is the error, wrapped, of a path that came to hold another file between being looked at and being opened, as when a log is rotated.

Functions

func CheckRegular

func CheckRegular(path string, info os.FileInfo) error

CheckRegular returns an error unless info, of what is at path, is of a regular file.

func Lines

func Lines(s string) []any

Lines returns the lines of s, without their line endings, \n or \r\n. The end of the last line is not a line of its own, so the lines of a file are those an editor shows, and an empty s has none.

func Read

func Read(path string, limit int) (string, error)

Read returns the content of the file at path, relative to the working directory, as the paths of actions are. Only a regular file is read, and no more of it than limit bytes: a device such as /dev/zero, or a file that grows while it is read, would otherwise be read on and on. A larger file is an error rather than cut short.

func ReadOpened

func ReadOpened(path string, info os.FileInfo, limit int) (string, error)

ReadOpened opens the file at path and reads it, as Read does, once info, what was found at path before it was opened, is known to be of a regular file. The file opened must be the one info is of.

Types

This section is empty.

Jump to

Keyboard shortcuts

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