Skip to content
/ impi Public
forked from pavius/impi

Verify proper golang import directives, beyond the capability of gofmt and goimports.

License

Notifications You must be signed in to change notification settings

tnmurphy/impi

 
 

Repository files navigation

Build Status Go Report Card

impi

Verify proper golang import directives, beyond the capability of gofmt and goimports. Rather than just verifying import order, it classifies imports to three types:

  1. Std: Standard go imports like fmt, os, encoding/json
  2. Local: Packages which are part of the current project
  3. Third party: Packages which are not standard and not local

It can then verify, according to the chosen scheme, that each import resides in the proper import group. Import groups are declared in the import() directive and are separated by an empty line:

import(
    "Group #1 import #1"
    "Group #1 import #2"

    "Group #2 import #1"
    "Group #2 import #2"
    // comments are allowed within a group
    "Group #2 import #3"

    "Group #3 import #1"
    "Group #3 import #2"
)

Note that impi does not support regenerating the files, only warns of infractions.

Usage

go get -u github.com/pavius/impi/cmd/impi
impi [--local <local import prefix>] [--ignore-generated=<bool>] --scheme <scheme> <packages>

nuclio uses impi as follows:

impi --local github.com/nuclio/nuclio/ --scheme stdLocalThirdParty ./cmd/... ./pkg/...

Ignoring Generated Files

Set --ignore-generated=true to ignore files that have been generated by go generate.

Supported schemes

impi currently supports the following schemes:

  1. stdLocalThirdParty: Std -> Local -> Third party
  2. stdThirdPartyLocal: Std -> Third party -> Local

impi will obviously not fail if a group is missing. For example, stdThirdPartyLocal also allows Std -> Local, Third party -> Local, etc.

About

Verify proper golang import directives, beyond the capability of gofmt and goimports.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%