Count lines matching a pattern across multiple log files in a Go program without dropping into a shell script.
Make HTTP GET requests and filter the JSON response with a JQ query inside a Go CLI tool.
Build a file-processing tool that reads from files or stdin interchangeably with minimal code changes.
Chain text transformations like filtering, slicing, and converting output in a single readable expression.
Pure Go library, add it with go get and import it, no external binaries or system dependencies required.
This is a Go library called script that lets developers write programs in the Go programming language that work like shell scripts. Shell scripts are small programs people write for the command line, usually to read files, search text, run other programs, and chain those operations together. Normally you would do that in a language like Bash. This library brings that same style of working into Go. The core idea is a pipeline: you start with a source of data, pass it through a series of transformations, and send the result somewhere. A source might be a file, the text you type into a terminal, command-line arguments, or an HTTP request. Transformations include things like filtering lines that match a word, converting text to uppercase, grabbing only the first N results, or running each line through an external program. The result can go to the terminal, to a file, or be returned as a string in your program. For example, to count how many lines in a log file contain the word "Error", you would write three chained calls: open the file, filter to matching lines, then count. To make the same program work on input piped from the terminal instead of a file, you swap one word. To grab matching lines from multiple files passed as command-line arguments, you swap another word. The library tries to make those kinds of changes feel natural. It also handles HTTP: you can make GET or POST requests and pipe the response through the same transformations. There is support for running JQ queries against JSON responses, which is a way to extract specific fields from structured data. Error handling follows the pipeline: if any step fails, subsequent steps quietly produce no output, and you can check the error at the end. This avoids writing nested error checks for every step. The library is aimed at Go developers who want to write system administration tools or automation scripts without switching to a shell language. It is not a tool for end users, you need to write Go code to use it.
← bitfield on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.