Init initializes configuration.
()
| 82 | |
| 83 | // Init initializes configuration. |
| 84 | func Init() error { |
| 85 | // Load environment variables from local files. |
| 86 | godotenv.Load() |
| 87 | |
| 88 | // Set the log level. |
| 89 | util.BuildLogger(os.Getenv("LOG_LEVEL")) |
| 90 | |
| 91 | // Load translation files. |
| 92 | if err := LoadLocales("conf/locales/zh-cn.yaml"); err != nil { |
| 93 | return fmt.Errorf("load locales: %w", err) |
| 94 | } |
| 95 | |
| 96 | // Connect to the database. |
| 97 | dsn, err := DatabaseDSN() |
| 98 | if err != nil { |
| 99 | return err |
| 100 | } |
| 101 | |
| 102 | model.Database(dsn) |
| 103 | cache.Redis() |
| 104 | return nil |
| 105 | } |
no test coverage detected