golines – Shorten Long Lines in Go Source Code

golines is a command-line formatter for Go that focuses on shortening source lines that exceed a chosen width. It works with Go syntax rather than treating source as plain text, adjusting line breaks around suitable constructs before passing the result through a base formatter.

The formatter is intended for developers who want automated control over line length while retaining conventional Go formatting. It can process files, directories, or standard input and can either print results, show changes, or update source files directly.

This is free and open source software.

Key Features

  • Shortens Go source lines beyond a configurable maximum width.
  • Lets users configure the tab width used in length calculations.
  • Handles individual files, directories, and standard input.
  • Can update source files in place.
  • Provides a dry-run mode with Git-style diffs.
  • Uses goimports as its preferred base formatter when available.
  • Falls back to gofmt when goimports is unavailable.
  • Allows an alternative base formatter to be selected explicitly.
  • Skips generated files by default.
  • Can optionally shorten single-line comments.
  • Supports alternative splitting of chained method calls.
  • Can reformat struct tag alignment when that option is enabled.

Website: github.com/golangci/golines
Support:
Developer: Golangci Team
License: MIT License

golines is written in Go. Learn Go with our recommended free books and free tutorials.

Related Software

Go Code Formatters
goimports-reviserSorts and groups imports by standard, third-party and project packages
gofumptEnforces stricter styling rules for cleaner, consistent source
gofmtApplies standardised indentation, spacing and source layout
golinesBreaks lengthy statements into readable, shorter lines
goimportsAutomatically adds missing imports and removes unused ones
gocondenseCombines multiline constructs to reduce unnecessary vertical space

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted