Ordino
This package sorts Go imports in groups and in a default or user-defined order.
Shoulders
This customized package uses a lot of the logic and some tools from goimports-reviser
Requirements
Usage
Install it by running:
go install github.com/Project-Centurion/ordino@latest
ordino -project-name [YourProjectName] -output [TheOutPutYouWant] -order [thePackagesOrderYouWant] [file/path/to/your/gofile.go]
Required arguments
file/path/to/your/gofile.go
: the path from the current directory to the file where you want your imports sorted.
./...
: sorts imports from all the .go
files under the current directory
example :
ordino -project-name [YourProjectName] ./...
Optional arguments
theOutPutYouWant
: either file
or stdout
, by default file
(will rewrite the files sorted).
thePackagesOrderYouWant
: constructed like this std,alias,project,general
by default, meaning the order you want between
the packages, separated by commas, no spaces. Aliased packages being separated are optional.
YourProjectName
: the imports you want sorted as project
imports. Please provide the path to those imports such as github.com/MyGreatProject
or github.com/MyGreatProject/mySuperGreatGoRepository
. If not set, the project name will be fetched from go.mod
Real life examples:
ordino -order std,project,general -project-name github.com/Project-Centurion/ordino ./...
ordino -order project,general,std -output stdout main.go