Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pavius/impi
Verify proper golang import directives, beyond the capability of gofmt and goimports.
https://github.com/pavius/impi
go import linter
Last synced: 3 months ago
JSON representation
Verify proper golang import directives, beyond the capability of gofmt and goimports.
- Host: GitHub
- URL: https://github.com/pavius/impi
- Owner: pavius
- License: mit
- Created: 2017-10-04T21:22:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-10T23:33:37.000Z (over 3 years ago)
- Last Synced: 2024-06-18T18:42:15.223Z (5 months ago)
- Topics: go, import, linter
- Language: Go
- Size: 146 KB
- Stars: 24
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/pavius/impi.svg)](https://travis-ci.org/pavius/impi)
[![Go Report Card](https://goreportcard.com/badge/github.com/pavius/impi)](https://goreportcard.com/report/github.com/pavius/impi)## 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 localIt 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 ] [--ignore-generated=] --scheme
```[nuclio](https://github.com/nuclio/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.