Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>go-linesNew to Visual Studio Code? Get it now.
go-lines

go-lines

gofenix

|
1,764 installs
| (1) | Free
| Sponsor
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

go-lines

Visual Studio Marketplace Version

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:

myMap := map[string]string{"first key": "first value", "second key": "second value", "third key": "third value", "fourth key": "fourth value", "fifth key": "fifth value"}

vs.

myMap := map[string]string{
	"first key": "first value",
	"second key": "second value",
	"third key": "third value",
	"fourth key": "fourth value",
	"fifth key": "fifth value",
}

Thanks golines, we built a vscode extension to solve this problem.

Usage

First, install the tool. If you're using golang 1.18 or newer, run:

go install github.com/segmentio/golines@latest

Then, install this extension in Visual Studio Code:

  1. Open the Extensions view by clicking on the extensions icon in the sidebar or by navigating to View > Extensions.
  2. Search for "go-lines" in the search box.
  3. Click the Install button.
  4. Click the Reload button.

Q&A

  1. How to use this extension?

    This extension is designed to be used with the go tooling in Visual Studio Code. It will automatically format your code when you save a file.

  2. How many width can I format at once?

    150 characters is the default limit, but you can change it in the settings.

     "go-lines.lineLength": 120,
    

License

MIT License © 2023 Fenix

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft