// Package config handles the configuration aspects of the KetoTrack application. // It includes definitions and routines necessary for setting up and retrieving // application configuration settings, such as data storage paths. package config import ( "os" "path/filepath" ) // AppConfig holds configuration details for the application. It currently // only includes the path to the data storage location. type AppConfig struct { DataPath string } // Load initializes the application configuration by ensuring the required // directories exist and setting the path for data storage. It creates a // directory named ".ketotrack" in the user's home directory if it does not already // exist, and sets the data path to "records.json" within this directory. // The function loads these settings into an AppConfig instance and returns it. func Load() AppConfig { // TODO: Handle os.UserHomeDir errors // TODO: Handle os.MkdirAll errors homeDir, _ := os.UserHomeDir() ketotrackDir := filepath.Join(homeDir, ".ketotrack") os.MkdirAll(ketotrackDir, 0770) return AppConfig{ DataPath: filepath.Join(ketotrackDir, "records.json"), } }