Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 1.52 KB

README.md

File metadata and controls

63 lines (47 loc) · 1.52 KB

go-import-lint

Version Build Status Go Report Card Coverage Status

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"
)

Installation

Go

go install github.com/hedhyw/go-import-lint/cmd/go-import-lint@latest

Usage example

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