From 09dccd386ea9fd747b3592b3272392e88dedcbc2 Mon Sep 17 00:00:00 2001 From: tom Date: Wed, 25 Sep 2024 11:16:57 +0800 Subject: [PATCH] Fix: Repair the logic for obtaining the configuration file path. 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 5d60def..b7bb275 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) }