diff --git a/config/config.go b/config/config.go index 46eb8ca..89ba822 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,6 @@ +// 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 ( @@ -5,15 +8,23 @@ import ( "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.MkdirAll error gracefully + // TODO: Handle os.UserHomeDir errors + // TODO: Handle os.MkdirAll errors homeDir, _ := os.UserHomeDir() ketotrackDir := filepath.Join(homeDir, ".ketotrack") - os.MkdirAll(ketotrackDir, 0770) // handle error appropriately + os.MkdirAll(ketotrackDir, 0770) return AppConfig{ DataPath: filepath.Join(ketotrackDir, "records.json"), }