diff options
| author | Bobby <[email protected]> | 2026-03-06 22:15:09 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-03-06 22:15:09 +0530 |
| commit | 3f07a4b6c745707f135a7a97e93b0fa770b67873 (patch) | |
| tree | 2a16507183d139da1338a61fc4f222d094fff138 /config/config.go | |
| parent | 7e32d634cd488b0f100b62ad29234951dc6fb6e3 (diff) | |
| download | dove-3f07a4b6c745707f135a7a97e93b0fa770b67873.tar.xz dove-3f07a4b6c745707f135a7a97e93b0fa770b67873.zip | |
Add configuration and logging modules with TOML support
- Implement configuration management in the config package
- Define constants and types for server and mailbox configurations
- Create functions for loading and parsing configuration files
- Introduce logging functionality with customizable log levels and formats
- Add error handling and messages for configuration and logging operations
- Include TOML utilities for default value application and content marshaling
Diffstat (limited to 'config/config.go')
| -rw-r--r-- | config/config.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..358fe72 --- /dev/null +++ b/config/config.go @@ -0,0 +1,36 @@ +package config + +import ( + "dove/messages" + "dove/utils/logger" +) + +var ( + IMAP imap + Mailbox mailbox + POP3 pop3 + Server server + SMTP smtp +) + +var ( + DataDir string + DevMode bool +) + +func init() { + DevMode = isDevelopmentMode() + osConfigDirectory := resolveOSConfigDirectory() + DataDir = resolveDataDirectory(DevMode, osConfigDirectory) + + configFilePath := resolveConfigFilePath(DevMode, osConfigDirectory) + if loadError := loadConfigFile(configFilePath); loadError != nil { + logger.Fatalf(LOG_PREFIX, messages.ConfigFileLoadFailed, loadError) + } + + for _, section := range []any{&Server, &SMTP, &IMAP, &POP3, &Mailbox} { + if parseError := parseSection(section); parseError != nil { + logger.Fatalf(LOG_PREFIX, messages.ConfigSectionParseFailed, parseError) + } + } +} |
