The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →golines is a Go formatter that breaks up overlong source lines where its syntax-aware rewriting can do so. Its upstream default limit is 100 columns, and it can preview changes or write them directly to files. The original Segmentio repository is archived; for new installations, its README points readers to a fork maintained by golangci-lint maintainers.
What golines does—and what it does not
gofmt and goimports format Go code, but do not shorten long lines. golines adds that capability: it identifies lines that exceed a configured length and restructures code when possible. It is an optional formatter for teams that want a line-length convention, not a guarantee that every line will fit the limit.
The project describes a process that marks overlong lines, parses code and annotations into a decorated syntax tree, adjusts newlines around syntax nodes, repeats while it can shorten further, and then applies a base formatter. This is the project’s account of its implementation, not a guarantee of a particular result for every construct.
Which golines repository should you use?
The original project is Segmentio’s golines repository. It entered functional maintenance mode in late 2024 and was archived on December 19, 2025. Its README points to a fork maintained by golangci-lint maintainers. The fork’s package documentation is available at pkg.go.dev/github.com/golangci/golines.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
For a new installation, the fork’s package page documents:
go install github.com/golangci/golines@latest
That command tracks the latest version published for the fork; check its current documentation and release requirements when choosing a version. The archived upstream README documents go install github.com/segmentio/golines@latest for Go 1.21 or newer and go install github.com/segmentio/golines@v0.9.0 for older Go versions, but those are instructions for the original repository, not the maintained fork. Upstream also notes that requirements vary by release: v0.10.0 and later required Go 1.18, while v0.13.0 requires at least Go 1.23 because of transitive dependencies. It recommends v0.9.x or v0.12.x for older Go versions. Confirm compatibility for the repository and release you select.
How to shorten long lines in Go code
After installing the executable, pass it one or more files or directories. Without a path, it reads Go source from standard input. By default, formatted output goes to standard output; use -w to overwrite files, or --dry-run to display a git-style diff before applying anything.
- Preview a file:
golines --dry-run path/to/file.go - Format a directory and write changes:
golines -w path/to/package - Format standard input: pipe Go source into
golines, then capture or inspect the output.
Review the diff before adopting the result, particularly where comments or unusual syntax are involved.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Set the line length and tab width
The upstream README documents a default maximum line length of 100 columns and an assumed tab width of four columns. Use -m to choose a different maximum and -t to set the tab width. For example, to request a 120-column limit while retaining the documented four-column tab assumption:
golines -m 120 -t 4 --dry-run path/to/package
These values guide the formatter’s shortening attempts; they do not force every resulting line under the requested width.
Rank #4
Comments need special attention
Comment shortening is disabled by default. The project says its basic handling of single-line // comments is less reliable because comments can have arbitrary structure. Enable --shorten-comments only if you want golines to attempt that work, and inspect the text and formatting afterward. Treat comment edits as content to review, not just whitespace changes.
Formatting behavior and practical limits
The upstream README says golines uses goimports as its base formatter when available and otherwise falls back to gofmt. The project explicitly acknowledges that it is imperfect, especially with long comment lines. It does not establish universal compatibility or guarantee a chosen line width.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsBest Value
Use a diff-based workflow first, then run your normal tests and formatting checks. If a particular file or part of a file must remain untouched, the available documentation cited here does not establish a specific exclusion mechanism; consult the selected fork’s current documentation rather than assuming one exists.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

