global.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package global
  2. import (
  3. "github.com/gin-gonic/gin"
  4. ut "github.com/go-playground/universal-translator"
  5. "github.com/go-playground/validator/v10"
  6. "github.com/go-redis/redis/v8"
  7. "github.com/lejianwen/rustdesk-api/config"
  8. "github.com/lejianwen/rustdesk-api/lib/cache"
  9. "github.com/lejianwen/rustdesk-api/lib/jwt"
  10. "github.com/lejianwen/rustdesk-api/lib/lock"
  11. "github.com/lejianwen/rustdesk-api/lib/upload"
  12. "github.com/nicksnyder/go-i18n/v2/i18n"
  13. "github.com/sirupsen/logrus"
  14. "github.com/spf13/viper"
  15. "gorm.io/gorm"
  16. )
  17. var (
  18. DB *gorm.DB
  19. Logger *logrus.Logger
  20. ConfigPath string = ""
  21. Config config.Config
  22. Viper *viper.Viper
  23. Redis *redis.Client
  24. Cache cache.Handler
  25. Validator struct {
  26. Validate *validator.Validate
  27. UT *ut.UniversalTranslator
  28. VTrans ut.Translator
  29. ValidStruct func(*gin.Context, interface{}) []string
  30. ValidVar func(ctx *gin.Context, field interface{}, tag string) []string
  31. }
  32. Oss *upload.Oss
  33. Jwt *jwt.Jwt
  34. Lock lock.Locker
  35. Localizer func(lang string) *i18n.Localizer
  36. )