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.
This commit is contained in:
tom 2024-09-25 11:16:57 +08:00
parent aef14559a1
commit 09dccd386e
1 changed files with 7 additions and 1 deletions

View File

@ -49,7 +49,13 @@ type config struct {
} }
func readConfig() *config { 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 { if nil != err {
log.Fatal(err) log.Fatal(err)
} }