Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanziw/importsort
https://github.com/kanziw/importsort
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanziw/importsort
- Owner: kanziw
- License: apache-2.0
- Created: 2021-09-26T07:19:49.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-26T07:58:02.000Z (over 3 years ago)
- Last Synced: 2024-06-20T09:58:23.432Z (7 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# importsort
> Inspired by https://github.com/aristanetworks/goarista/tree/master/cmd/importsort## What's this?
It sorts golang imports into 3 groups like -
1. Standard packages
2. Third-party packages
3. your (e.g. `cvshub.com/company`) packages```go
import (
"bytes"
"strings""github.com/pkg/errors"
a "cvshub.com/company/p"
"cvshub.com/company/q"
)
```## Install
```sh
go install github.com/kanziw/importsort@latest
```## Usage
```
Usage of importsort:
-l list files whose formatting differs from importsort
-s prefix
package prefix to define an import section, ex: "cvshub.com/company". May be specified multiple times. If not specified the repository root is used.
-w write result to file instead of stdout
```#### Example
```sh
importsort -s github.com/kanziw -w main.go
```### How to set in GoLand
1. Download [importsort.xml](./importsort.xml)
2. `Preferences` -> `Tools` -> `File Watchers` -> Import `importsort.xml`### How to set in VSCode
1. Install [File Watcher](https://marketplace.visualstudio.com/items?itemName=appulate.filewatcher)
2. Edit setting.json
```json
"filewatcher.commands": [
{
"match": "\\.go$",
"isAsync": true,
"cmd": "importsort -s cvshub.com/company -w ${file}",
"event": "onFileChange"
}
]
```