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.
This commit is contained in:
aliensb 2024-09-25 15:11:30 +08:00 committed by GitHub
parent 9ef70da47b
commit 6d9ba954dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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)
} }