Skip to content

Commit

Permalink
-- OPTIMIZE
Browse files Browse the repository at this point in the history
 -- Log warn when loaded json file is empty
  • Loading branch information
NoahAmethyst committed Nov 8, 2024
1 parent e96deea commit a42ab2b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion util/file_util/json_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ func WriteJsonFile(data interface{}, targetPath, fileName string, format bool) (

func LoadJsonFile(file string, data interface{}) error {
bytes, err := os.ReadFile(file)
if err != nil {
if len(bytes) == 0 {
log.Warnf("Json file [%s] is empty", file)
return nil
} else if err != nil {
log.Errorf("Read json file [%s] failed %s", file, err.Error())
return err
}
Expand Down

0 comments on commit a42ab2b

Please sign in to comment.