assignment.go 707 B

123456789101112131415161718192021222324252627282930313233
  1. package initialize
  2. import (
  3. "fmt"
  4. "github.com/RaymondCode/simple-demo/config"
  5. "github.com/RaymondCode/simple-demo/dao"
  6. "github.com/RaymondCode/simple-demo/service"
  7. "github.com/RaymondCode/simple-demo/util/snowflake"
  8. "os"
  9. "os/exec"
  10. "path/filepath"
  11. "strings"
  12. )
  13. func AssignMent() {
  14. Viper()
  15. dao.InitDb()
  16. service.InitRdsPool()
  17. service.InitOss()
  18. snowflake.InitSnowFlakeSeed()
  19. config.PROJECTPATH = GetRunPath2()
  20. }
  21. // 获取程序执行目录
  22. func GetRunPath2() string {
  23. file, _ := exec.LookPath(os.Args[0])
  24. path, _ := filepath.Abs(file)
  25. index := strings.LastIndex(path, string(os.PathSeparator))
  26. ret := path[:index]
  27. fmt.Println("视频存储url为" + ret + config.VIDEO_ADDR)
  28. return ret
  29. }