Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

goimports-reviser

> 编程语言
Open source

Right imports sorting & code formatting tool (goimports alternative)

715 stars0 likes0 views
WebsiteGitHub

About

Right imports sorting & code formatting tool (goimports alternative)


goimports-reviser

Tool for Golang to sort goimports by 3-4 groups(with own linter): std, general, company(which is optional) and project dependencies. Also, formatting for your code will be prepared(so, you don't need to use gofmt or goimports separately). Use additional options -rm-unused to remove unused imports and -set-alias to rewrite import aliases for versioned packages or for packages with additional prefix/suffix(example: opentracing "github.com/opentracing/opentracing-go"). -company-prefixes - will create group for company imports(libs inside your organization). Values should be comma-separated.

Configuration:

Cmd

bash
goimports-reviser -rm-unused -set-alias -format ./reviser/reviser.go

You can also apply rules to a dir or recursively apply using ./... as a target:

bash
goimports-reviser -rm-unused -set-alias -format -recursive reviser
bash
goimports-reviser -rm-unused -set-alias -format ./...

You can also apply rules to multiple targets:

bash
goimports-reviser -rm-unused -set-alias -format ./reviser/reviser.go ./pkg/...

Example, to configure it with JetBrains IDEs (via file watcher plugin):

Options:

…

Install

With Go

bash
go install -v github.com/incu6us/goimports-reviser/v3@latest

With Brew

bash
brew tap incu6us/homebrew-tap
brew install incu6us/homebrew-tap/goimports-reviser

With Snap

bash
snap install goimports-reviser

Examples

Before usage:

go
package testdata

import (
	"log"

	"github.com/incu6us/goimports-reviser/testdata/innderpkg"

	"bytes"

	"golang.org/x/exp/slices"
)

After usage:

go
package testdata

import (
	"bytes"
	"log"

	"golang.org/x/exp/slices"

	"github.com/incu6us/goimports-reviser/testdata/innderpkg"
)

Comments(not Docs) for imports is acceptable. Example:

go
package testdata

import (
    "fmt" // comments to the package here
)

Example with -company-prefixes-option

Before usage:

go
package testdata // goimports-reviser/testdata

import (
	"fmt" //fmt package
	"golang.org/x/exp/slices" //custom package
	"github.com/incu6us/goimports-reviser/pkg" // this is a company package which is not a part of the project, but is a part of your organization
	"goimports-reviser/pkg"
)

After usage:

go
package testdata // goimports-reviser/testdata

import (
	"fmt" // fmt package

	"golang.org/x/exp/slices" // custom package

	"github.com/incu6us/goimports-reviser/pkg" // this is a company package which is not a part of the project, but is a part of your organization

	"goimports-reviser/pkg"
)

Example with -imports-order std,general,company,project,blanked,dotted-option

Before usage:

go
package testdata // goimports-reviser/testdata

import (
	_ "github.com/pkg1"
	. "github.com/pkg2"
	"fmt" //fmt package
	"golang.org/x/exp/slices" //custom package
	"github.com/incu6us/goimports-reviser/pkg" // this is a company package which is not a part of the project, but is a part of your organization
	"goimports-reviser/pkg"
)

After usage:

go
package testdata // goimports-reviser/testdata

import (
	"fmt" // fmt package

	"golang.org/x/exp/slices" // custom package

	"github.com/incu6us/goimports-reviser/pkg" // this is a company package which is not a part of the project, but is a part of your organization

	"goimports-reviser/pkg"

	_ "github.com/pkg1"

	. "github.com/pkg2"
)

Example with -format-option

Before usage:

go
package main
func test(){
}
func additionalTest(){
}

After usage:

go
package main

func test(){
}

func additionalTest(){
}

Example with -separate-named-option

Before usage:

go
package testdata // goimports-reviser/testdata

import (
	"fmt"
	"github.com/incu6us/goimports-reviser/pkg"
	extpkg "google.com/golang/pkg"
	"golang.org/x/exp/slices"
	extslice "github.com/PeterRK/slices"
)

After usage:

go
package testdata // goimports-reviser/testdata

import (
	"fmt"

	"github.com/incu6us/goimports-reviser/pkg"
	"golang.org/x/exp/slices"

	extpkg "google.com/golang/pkg"
	extslice "github.com/PeterRK/slices"
)

Contributors

A big thank you to all the amazing people who contributed!

Give a Star! ⭐

If you like or are using this project, please give it a star.

Stargazers

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gogogofmtgoimportsgoimports-reviser

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言