gendao_clear.go 755 B

123456789101112131415161718192021222324252627282930
  1. // Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package gendao
  7. import (
  8. "context"
  9. "github.com/gogf/gf/v2/os/gfile"
  10. "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog"
  11. "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils"
  12. )
  13. func doClear(ctx context.Context, dirPath string, force bool) {
  14. files, err := gfile.ScanDirFile(dirPath, "*.go", true)
  15. if err != nil {
  16. mlog.Fatal(err)
  17. }
  18. for _, file := range files {
  19. if force || utils.IsFileDoNotEdit(file) {
  20. if err = gfile.Remove(file); err != nil {
  21. mlog.Print(err)
  22. }
  23. }
  24. }
  25. }