You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.go 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package config
  2. import (
  3. "github.com/spf13/viper"
  4. )
  5. type Config struct {
  6. Database DatabaseConfig
  7. RabbitMQ RabbitMQConfig
  8. Server ServerConfig
  9. }
  10. type DatabaseConfig struct {
  11. Host string
  12. Port string
  13. User string
  14. Password string
  15. DBName string
  16. }
  17. type RabbitMQConfig struct {
  18. Host string
  19. Port string
  20. User string
  21. Password string
  22. }
  23. type ServerConfig struct {
  24. Port string
  25. }
  26. func LoadConfig() *Config {
  27. viper.SetConfigFile("C:\\Users\\Administrator\\workspace\\workspace\\storage\\datamap\\.env")
  28. viper.ReadInConfig()
  29. return &Config{
  30. Database: DatabaseConfig{
  31. Host: viper.GetString("DB_HOST"),
  32. Port: viper.GetString("DB_PORT"),
  33. User: viper.GetString("DB_USER"),
  34. Password: viper.GetString("DB_PASSWORD"),
  35. DBName: viper.GetString("DB_NAME"),
  36. },
  37. RabbitMQ: RabbitMQConfig{
  38. Host: viper.GetString("RABBITMQ_HOST"),
  39. Port: viper.GetString("RABBITMQ_PORT"),
  40. User: viper.GetString("RABBITMQ_USER"),
  41. Password: viper.GetString("RABBITMQ_PASSWORD"),
  42. },
  43. Server: ServerConfig{
  44. Port: viper.GetString("SERVER_PORT"),
  45. },
  46. }
  47. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。