mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
This pull request refactors the way Go files are formatted after project generation in the `geninit` package. The main change is replacing the previous formatting utility with a new function that uses the standard library's `go/format` package, ensuring that only code formatting is applied and import paths are not inadvertently modified. **Formatting improvements:** * Replaced the use of `utils.GoFmt` with a new `formatGoFiles` function that utilizes `go/format` for formatting Go files, avoiding unwanted changes to local import paths. (`cmd/gf/internal/cmd/geninit/geninit_generator.go`) * Added the `formatGoFiles` function, which recursively formats all Go files in a directory using `go/format` and logs any formatting errors. (`cmd/gf/internal/cmd/geninit/geninit_generator.go`) * Updated comments and references in the code to clarify that formatting is now handled by `formatGoFiles` instead of `utils.GoFmt`. (`cmd/gf/internal/cmd/geninit/geninit_ast.go`) **Dependency changes:** * Removed the import of the custom `utils` package and added the standard `go/format` package to support the new formatting approach. (`cmd/gf/internal/cmd/geninit/geninit_generator.go`)