feat: first working version

This commit is contained in:
nihonium 2026-01-14 12:55:21 +03:00
parent a67e208d6e
commit 1029563cb1
11 changed files with 585 additions and 0 deletions

53
internal/config/config.go Normal file
View file

@ -0,0 +1,53 @@
package config
import (
"os"
"github.com/pelletier/go-toml/v2"
)
/**
* @brief Структура конфигурации приложения
*/
type Config struct {
App struct {
Name string `toml:"name"`
MaxLoginAttempts int `toml:"max_login_attempts"`
LockTimeoutSec int `toml:"lock_timeout_sec"`
} `toml:"app"`
Database struct {
Type string `toml:"type"`
Path string `toml:"path"`
} `toml:"database"`
Security struct {
PasswordHash string `toml:"password_hash"`
} `toml:"security"`
UI struct {
ShowWelcome bool `toml:"show_welcome"`
} `toml:"ui"`
}
/**
* @brief Загрузка конфигурации из TOML файла
*
* @param path путь к файлу конфигурации
* @return cfg указатель на структуру Config
* @return error ошибка при загрузке
*/
func Load(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
var cfg Config
err = toml.Unmarshal(data, &cfg)
if err != nil {
return nil, err
}
return &cfg, nil
}