create config package

This commit is contained in:
agatha 2024-05-12 15:46:06 -04:00
parent 9b0597e680
commit de0a3b3e85

20
config/config.go Normal file
View File

@ -0,0 +1,20 @@
package config
import (
"os"
"path/filepath"
)
type AppConfig struct {
DataPath string
}
func Load() AppConfig {
// TODO: Handle os.MkdirAll error gracefully
homeDir, _ := os.UserHomeDir()
ketotrackDir := filepath.Join(homeDir, ".ketotrack")
os.MkdirAll(ketotrackDir, 0770) // handle error appropriately
return AppConfig{
DataPath: filepath.Join(ketotrackDir, "records.json"),
}
}