升级FileType枚举类型定义
This commit is contained in:
4
file.go
4
file.go
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user