This repository has been archived on 2025-11-19. You can view files and clone it, but cannot push or open issues or pull requests.
Skyfeed_archive/internal/config/config.go

39 lines
814 B
Go

package config
import (
"fmt"
"os"
"path/filepath"
)
// Global app paths (used by all other packages)
var (
ConfigDir string
CacheDir string
DataDir string
)
// Init creates the required directories and prints their paths if missing.
func Init() {
home, err := os.UserHomeDir()
if err != nil {
fmt.Println("Error: cannot resolve home directory:", err)
os.Exit(1)
}
ConfigDir = filepath.Join(home, ".config", "skyfeed")
CacheDir = filepath.Join(home, ".cache", "skyfeed")
DataDir = filepath.Join(home, ".local", "share", "skyfeed")
dirs := []string{ConfigDir, CacheDir, DataDir}
for _, dir := range dirs {
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, 0755)
if err != nil {
fmt.Printf("Error creating %s: %v\n", dir, err)
os.Exit(1)
}
}
}
}