global.go 904 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package global
  2. import (
  3. "Gwen/config"
  4. "Gwen/lib/cache"
  5. "Gwen/lib/jwt"
  6. "Gwen/lib/lock"
  7. "Gwen/lib/upload"
  8. "github.com/gin-gonic/gin"
  9. ut "github.com/go-playground/universal-translator"
  10. "github.com/go-playground/validator/v10"
  11. "github.com/go-redis/redis/v8"
  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. Config config.Config
  21. Viper *viper.Viper
  22. Redis *redis.Client
  23. Cache cache.Handler
  24. Validator struct {
  25. Validate *validator.Validate
  26. UT *ut.UniversalTranslator
  27. VTrans ut.Translator
  28. ValidStruct func(*gin.Context, interface{}) []string
  29. ValidVar func(ctx *gin.Context, field interface{}, tag string) []string
  30. }
  31. Oss *upload.Oss
  32. Jwt *jwt.Jwt
  33. Lock lock.Locker
  34. Localizer func(ctx *gin.Context) *i18n.Localizer
  35. )