first commit

This commit is contained in:
2026-02-06 21:08:15 +03:00
commit 2d7bd20ac0
12 changed files with 395 additions and 0 deletions

38
internal/config/config.go Normal file
View File

@@ -0,0 +1,38 @@
package config
import (
"fmt"
"os"
"github.com/joho/godotenv"
)
type Config struct {
ServerHost string
ServerPort string
RedisURL string
}
func Load() (*Config, error) {
_ = godotenv.Load()
cfg := &Config{
ServerHost: os.Getenv("SERVER_HOST"),
ServerPort: os.Getenv("SERVER_PORT"),
RedisURL: os.Getenv("REDIS_URL"),
}
if cfg.ServerHost == "" {
cfg.ServerHost = "localhost"
}
if cfg.ServerPort == "" {
return nil, fmt.Errorf("server port is required")
}
if cfg.RedisURL == "" {
return nil, fmt.Errorf("redis connection url is required")
}
return cfg, nil
}