mz.attahri.com/code/lines

66 views
Skip to first unread message

Mohamed Zane Attahri

unread,
Dec 1, 2025, 6:56:42 PM (2 days ago) Dec 1
to golang-nuts

Hi all,

I’d like to share lines (github.com/mzattahri/lines), a library for reading, searching, and modifying text sources on a per-line basis. It uses iterators and simple abstractions that make it ergonomic to traverse, filter, rewrite, or transform text line by line.  

What it does:

(a) Iterate over all lines (forward or backward), or head/tail subsets.  

(b) Search/filter lines by content or custom predicates.

(c) Modify files in place (replace, remove, insert, truncate) or rewrite/transform them safely using a buffered rewrite or streaming.

(d) Maintain 1-based line numbering consistently (even when iterating backwards or slicing).

Why it might be useful:

(1) For tooling that deals with text files (config files, logs, code, data), where you often want to inspect or change specific lines without rewriting the whole file manually.

(2) For simple command-line utilities or small Go programs where full AST-based parsing is overkill, but line-based scanning or editing is sufficient.

(3) When you prefer a straightforward API with minimal dependencies and clear semantics around iteration and modification.

Thoughts and feedback are welcome.

ben...@gmail.com

unread,
Dec 2, 2025, 4:47:49 PM (14 hours ago) Dec 2
to golang-nuts
This look nicely done, thanks for sharing!
Reply all
Reply to author
Forward
0 new messages