Skip to content

charlievieth/gosortimports

Repository files navigation

gosortimports

Command gosortimports is a more aggressive version of goimports that handles very badly grouped imports and adds gofmt's simplify code option (-s). Otherwise it is the same as goimports.

Note: Since gosortimports undoes any existing import groupings it is recommended to run it with the -local flag so that it can properly group local imports. At some point gosortimports will support automatically deducing the value of the local flag.

Installation

go install github.com/charlievieth/gosortimports

Examples

The two following examples shows how gosortimports more aggressively handles oddly grouped imports compared to goimports.

import (
	"io"

	"m/a"

	"math"

	"fmt"
	"m/b"
)

// formatted with: `goimports -local=m/`

import (
	"io"

	"m/a"

	"math"

	"fmt"

	"m/b"
)

// formatted with: `gosortimports -local=m/`

import (
	"fmt"
	"io"
	"math"

	"m/a"
	"m/b"
)

About

gosortimports is a fork of goimports that aggressively re-groups imports

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages