Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

golines is very slow when using goimports as a base formatter (in a zsh shell) #155

Description

@mathieu-lemay

I was investigating yesterday why golines was so slow on our projects and I noticed that switching to gofmt as a base formatter makes it massively faster, by about two orders of magnitude.

With gofmt:

golines -w --base-formatter="gofmt" **/*.go  0.05s user 0.02s system 74% cpu 0.090 total

With goimports:

golines -w --base-formatter="goimports" **/*.go  54.97s user 313.56s system 822% cpu 44.821 total

I unfortunately can't share the code as an example, but I do reproduce those results by running golines on https://github.com/rs/zerolog, using commit 6abadab
The difference is less staggering on zerolog, but still very much present, about 0.2s vs 16.4s.

Strangely enough, if I run golines with goimports, but from bash shell, the time goes down to about the same level than when using gofmt.

I'm using go v1.23.3 and golines@13c3f0d

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions