add check for invalid img path

This commit is contained in:
Benny~ 2020-03-07 13:08:07 +08:00
parent 6b266e8fb7
commit e2e39e0690
No known key found for this signature in database
GPG Key ID: 6CD0DBDA5235D481

View File

@ -67,6 +67,11 @@ func loadConfig(path string) Config {
defer jsonObject.Close()
decoder := json.NewDecoder(jsonObject)
_ = decoder.Decode(&config)
_, err = os.Stat(config.ImgPath)
if err != nil {
log.Fatalf("Your image path %s is incorrect.Please check and confirm.", config.ImgPath)
}
return config
}