Skip to content

Golang source code analyzer that checks imports order. It verifies that standard, current package, and vendor imports are separated by a line.

License

Notifications You must be signed in to change notification settings

hedhyw/go-import-lint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Golang source code analyzer that checks imports order. It verifies that standard, current package, and vendor imports are separated by a line.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published