main.go 787 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. "git.wecise.com/wecise/cgimport/cgf"
  6. "git.wecise.com/wecise/util/cfg"
  7. )
  8. // 获取配置信息
  9. //
  10. // 默认配置:
  11. // 当前工作目录下 与应用同名的 .conf 文件
  12. // 环境变量
  13. // 命令行参数
  14. var mcfg = cfg.MConfig()
  15. func main() {
  16. // 开始计时
  17. st := time.Now()
  18. // 配置参数
  19. // 文件目录
  20. datapath := mcfg.GetString("datapath", "data")
  21. // 并发数
  22. parallel := mcfg.GetInt("parallel", 10)
  23. // 导入
  24. filescount, recordscount, e := cgf.ImportDir(datapath, parallel)
  25. if e != nil {
  26. panic(e)
  27. }
  28. if filescount == 0 {
  29. fmt.Println(`not found data files in "` + datapath + `"`)
  30. return
  31. }
  32. // 输出统计信息
  33. fmt.Println("total import", filescount, "files", recordscount, "records", "in", time.Since(st))
  34. }