升级FileType枚举类型定义

This commit is contained in:
2024-11-25 16:18:53 +08:00
parent 42ae8fe5eb
commit 2d10d261da
4 changed files with 27 additions and 3 deletions

View File

@ -154,7 +154,7 @@ func (f *file) ReadAnyFileContent(filePath string, receiver any) error {
parseFunc func(filePath string, receiver any) error
)
fileExt := strings.TrimLeft(strings.ToLower(path.Ext(filePath)), ".")
fileExt := consts.FileType(strings.TrimLeft(strings.ToLower(path.Ext(filePath)), "."))
switch fileExt {
case consts.FileTypeJson:
parseFunc = f.ReadJSONContent
@ -167,7 +167,7 @@ func (f *file) ReadAnyFileContent(filePath string, receiver any) error {
case consts.FileTypeXml:
parseFunc = f.ReadXmlContent
default:
return errors.New(fileExt + " 暂不支持当前格式的文件解析")
return errors.New(fileExt.String() + " 暂不支持当前格式的文件解析")
}
return parseFunc(filePath, receiver)
}