Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mathieu-lemay opened this issue Oct 30, 2024 · 2 comments

Comments

@mathieu-lemay
Copy link

mathieu-lemay commented Oct 30, 2024

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

@abraithwaite
Copy link

Same here! Amazing I found this right when you posted it.

@mathieu-lemay
Copy link
Author

@abraithwaite Talk about coincidence!

Btw, I just found out about https://github.com/incu6us/goimports-reviser which I already prefer to goimports since it it more thorough. It also doesn't cause the slowness when used as a base formatter for golines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants