Repository navigation
Repository tools imports formatter README
alanxtl edited this page Sep 20, 2026
·
1 revision
主仓库文档快照;main 的说明不自动适用于所有已发布版本。 来源:原文 · 提交
832124aaacf0· 返回目录
English | 中文
imports-formatter rewrites Go import blocks using the grouping style used by dubbo-go.
It scans a Go module, skips generated files that contain Code generated by, and groups imports into:
- Go standard library imports
- third-party imports
- current module imports
go install dubbo.apache.org/dubbo-go/v3/tools/imports-formatter@latestMake sure $(go env GOPATH)/bin is in your PATH.
You can also install it through dubbogo-cli:
dubbogo-cli install formatterFormat the current module:
imports-formatterFormat a specific module path:
imports-formatter --path /path/to/modulePass the module path explicitly when the target directory does not contain go.mod:
imports-formatter --path /path/to/module/subdir --module dubbo.apache.org/dubbo-go/v3Disable blank lines between third-party import groups:
imports-formatter --bl=false| Flag | Default | Description |
|---|---|---|
--path |
current directory | Directory to scan recursively. |
--module |
module from go.mod
|
Go module path used to identify internal imports. |
--bl |
true |
Whether to insert blank lines between third-party import groups. |
imports-formatter edits files in place. Review the diff before committing.