Go-lines is a golang formatter that shortens long lines, in addition to all of the formatting fixes done by gofmt.
Why Format your code?
Everyone loves clean readable and beautifully organized code using tabs/spaces (whatever you like), short lines etc. As a developer, while writing code, you should not spend time counting the tabs/spaces, instead let the tools handle your code formatting for you and that too automatically.
The standard golang formatting tools (gofmt, goimports, etc.) are great, but deliberately don't shorten long lines; instead, this is an activity left to developers.
While there are different tastes when it comes to line lengths in go, we've generally found that very long lines are more difficult to read than their shortened alternatives. As an example:
Thanks golines, we built a vscode extension to solve this problem.
First, install the tool. If you're using golang 1.18 or newer, run:
Then, install this extension in Visual Studio Code: