From f338aea28872e02cb23a0187be596a8b30b6f0e1 Mon Sep 17 00:00:00 2001 From: agatha Date: Sun, 12 May 2024 17:03:47 -0400 Subject: [PATCH] docs: config package --- config/config.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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"), }