Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 2.08 KB

readme-cn.md

File metadata and controls

62 lines (46 loc) · 2.08 KB

goimportx

Go License: MIT Go Reference

中文|English

goimportx 是一个 go 包导入排序的 cli 工具,其继承了 goimports 的排序逻辑,又增强了一些 goimports 没有的特新。

特性

  • 自动排序和分组 go 包导入。
  • 支持自定义分组规则。
  • 支持将结果写入文件。
  • 仅支持 go module。
  • 使用 go 官方排序算法.
  • 当只有一个 import 时自动去除括号
  • 自动移除空白行
特性 goimports goimportx
自动排序和分组 go 包导入
支持自定义分组规则
支持将结果写入文件
当只有一个 import 时自动去除括号
自动移除空白行
支持多文件、多目录

安装

$ go install github.com/anqiansong/goimportx@latest

Usage

$ goimportx --dir /path/to/dir --file /path/to/file.go

Help

goimportx --help
sort and group go imports

Usage:
  goimportx [flags]

Examples:
goimportx --dir path/to/your/dir --file /path/to/file.go --group "system,local,third"

Flags:
  -d, --dir strings    file directory
  -f, --file string    file path
  -g, --group string   group rule, split by comma, only supports [system,local,third,others] (default "system,local,third")
  -h, --help           help for goimportx
  -v, --version        version for goimportx
  -w, --write          write result to (source) file instead of stdout