修复文件格式解析的BUG

This commit is contained in:
白茶清欢 2024-11-07 18:16:41 +08:00
parent ecb0211345
commit 2e4508468f

10
file.go
View File

@ -153,14 +153,8 @@ func (f *file) ReadAnyFileContent(filePath string, receiver any) error {
var (
parseFunc func(filePath string, receiver any) error
)
filePathArr := strings.Split(filePath, "#@#")
fileExt := ""
filePath = filePathArr[0]
if len(filePathArr) == 2 && len(filePathArr[1]) > 0 {
fileExt = strings.ToLower(filePathArr[1])
} else {
fileExt = strings.ToLower(path.Ext(filePath))
}
fileExt := strings.TrimLeft(strings.ToLower(path.Ext(filePath)), ".")
switch fileExt {
case consts.FileTypeJson:
parseFunc = f.ReadJSONContent