chore: clarify company prefix guide

main
sudo pacman -Syu 2023-01-22 11:45:49 +07:00
parent d539b904cc
commit bd8fef108c
2 changed files with 10 additions and 15 deletions

View File

@ -9,13 +9,8 @@ First is **standard**.
Then **third party**, then **company** if exist. Then **third party**, then **company** if exist.
The last is **local**. The last is **local**.
Also main selling point of this tool is to group imports not sort them. Also main selling point of this tool is to handle imports only.
So please run `gofumpt` or `gofmt` after running this tool. So please run `gofumpt` or `gofmt` to format you files after running this tool.
Under the hood, this tool get all imports, then group them into 4 groups (std, third party, company, local).
Remember, **no** sort here.
Then insert empty import (empty path) between each group to get final imports
Then update Go ast decls import with final imports.
## Install ## Install
@ -28,12 +23,12 @@ go install github.com/haunt98/gofimports/cmd/gofimports@latest
## Usage ## Usage
```sh ```sh
# Format ./internal # Format ./internal with:
# with print impacted file (-l), # - print impacted file (-l),
# write to file (-w), # - write to file (-w),
# print diff (-d) # - print diff (-d)
# company is github.com/make-go-great # - company prefix, split using comma (,)
gofimports -l -company github.com/make-go-great -w -d ./internal gofimports -l -w -d --company github.com/make-go-great,github.com/haunt98 ./internal
``` ```
Example result: Example result:
@ -54,7 +49,7 @@ import (
## Roadmap ## Roadmap
- [ ] Diff with color - [ ] Diff with color
- [ ] Add profiling - [x] Add profiling
- [ ] Improve performance - [ ] Improve performance
## Thanks ## Thanks

View File

@ -14,7 +14,7 @@ const (
// Inspiration from gofmt flags // Inspiration from gofmt flags
flagCompanyPrefixName = "company" flagCompanyPrefixName = "company"
flagCompanyPrefixUsage = "company prefix, for example github.com/haunt98" flagCompanyPrefixUsage = "company prefix, split using comma (,), for example github.com/make-go-great,github.com/haunt98"
flagListName = "list" flagListName = "list"
flagListUsage = "list files will be changed" flagListUsage = "list files will be changed"