Golang source code analyzer that checks imports order. It verifies that:
- standard, current package, and vendor imports are separated by a line;
- there are no blank lines between one import group;
- there are no more than two lines.
Example of good imports order:
package main
// CGo import.
import "C"
import (
// Standart imports.
"fmt"
"error"
// Current package imports.
"github.com/hedhyw/go-import-lint/internal/linter"
"github.com/hedhyw/go-import-lint/internal/model"
// External imports.
"github.com/hedhyw/jsonscjson"
"github.com/stretchr/testify/assert"
// Unused imports.
_ "github.com/lib/pq"
)
go install github.com/hedhyw/go-import-lint/cmd/go-import-lint@latest
Run:
go-import-lint
Usage of go-import-lint:
-exclude value
paths to exclude (default ./vendor, ./.git)
-path value
paths to lint (default ./...)
-pkg string
module package