A Go code formatter that automatically shortens long lines beyond what gofmt provides.
Golines is a Go code formatter that automatically shortens long lines, which standard Go tools like gofmt deliberately omit. It helps maintain readable code by breaking down excessively long lines according to configurable preferences, such as maximum line length and method chain splitting. Additionally, it performs formatting fixes like struct tag alignment and integrates with base formatters like goimports.
Go developers who prioritize code readability and want automated enforcement of line length limits, particularly those working on large codebases or teams where consistent formatting is crucial. It's also useful for developers who use method chaining or complex structs and need tools to format these constructs cleanly.
Developers choose Golines because it fills a gap left by standard Go formatting tools by automatically shortening long lines, reducing manual effort and improving code consistency. Its unique selling point is the combination of line shortening with configurable options like method chain splitting and struct tag alignment, offering more control over formatting than gofmt alone.
A golang formatter that fixes long lines
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Fills a key gap left by gofmt by automatically breaking lines exceeding a configurable maximum length (default 100 columns), as highlighted in the motivation section with examples of improved readability.
Reformats and aligns struct tag keys for consistency, with before-and-after examples provided in the _fixtures directory, enhancing code structure without manual effort.
Offers configurable options to split long method chains on dots or arguments, with the default splitting on dots for cleaner code, as detailed in the chained method splitting section.
Includes a --dry-run flag that shows git-style diffs without modifying files, allowing developers to preview changes safely before applying them.
The repository was archived in 2025, with the README noting that dependencies are similarly unmaintained, meaning no future bug fixes, security patches, or feature updates from the original maintainers.
Comment shortening is described as basic and turned off by default because the quality isn't great, limiting its utility for formatting long comments without manual intervention.
For some editors like Visual Studio Code, integration requires installing third-party extensions and manual JSON configuration, which is more involved than using built-in formatters.