From 6d9ba954ddeadecd6717ee941e79363ac7be6926 Mon Sep 17 00:00:00 2001 From: aliensb Date: Wed, 25 Sep 2024 15:11:30 +0800 Subject: [PATCH] Fix: Repair the logic for obtaining the configuration file path. (#60) Fixed the logic for obtaining the configuration file path to ensure that config.json is used as the default when no command line arguments are provided. --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 8209e67..78f8215 100644 --- a/main.go +++ b/main.go @@ -49,7 +49,13 @@ type config struct { } func readConfig() *config { - content, err := os.ReadFile("config.json") + var configPath string + if len(os.Args) > 1 { + configPath = os.Args[1] + } else { + configPath = "config.json" + } + content, err := os.ReadFile(configPath) if nil != err { log.Fatal(err) }