Compare commits

...

3 Commits

Author SHA1 Message Date
sudo pacman -Syu c518272fb9 chore: add golds (wip) 2023-01-18 00:04:49 +07:00
sudo pacman -Syu 8d5c63b8db chore: improve docs 2023-01-17 23:58:44 +07:00
sudo pacman -Syu 3b35876b7f chore(changelog): generate v0.0.5 2023-01-17 23:55:08 +07:00
3 changed files with 25 additions and 7 deletions

View File

@ -1,5 +1,21 @@
# CHANGELOG
## v0.0.5 (2023-01-17)
### Added
- feat: cache module name even when read dir to improve perf (2023-01-17)
- feat: use sync.Pool to reuse bytes.Buffer (2023-01-17)
- feat: add profiler (2023-01-17)
- feat: add go profiler (2023-01-17)
### Others
- chore(changelog): generate v0.0.4 (2023-01-17)
## v0.0.4 (2023-01-17)
### Added

View File

@ -1,4 +1,4 @@
.PHONY: all test test-color coverage coverage-cli coverate-html lint format build
.PHONY: all test test-color coverage coverage-cli coverate-html lint format build clean docs
all: test-color lint format
go mod tidy
@ -33,3 +33,7 @@ build: clean
clean:
rm -rf gofimports
docs:
go install go101.org/golds@latest
golds ./...

View File

@ -45,11 +45,9 @@ var bufPool = sync.Pool{
},
}
// stdPackages -> save std packages for later search
//
// moduleNames -> map path to its go.mod module name
//
// formattedPaths -> make sure we not format path more than 1 time
// stdPackages -> save std packages for later search.
// moduleNames -> map path to its go.mod module name.
// formattedPaths -> make sure we not format path more than 1 time.
type Formatter struct {
stdPackages map[string]struct{}
moduleNames map[string]string
@ -234,7 +232,7 @@ func (ft *Formatter) formatFile(path string) error {
// First parse ast.
// Then group imports.
// Then format imports.
// Then print.
// Then print to bytes.
func (ft *Formatter) formatImports(
path string,
pathBytes []byte,