序列化增加接口约束

This commit is contained in:
2024-10-23 17:04:10 +08:00
parent d02ff0d1e0
commit 454b1e8ac6
3 changed files with 56 additions and 22 deletions

12
file.go
View File

@ -67,7 +67,7 @@ func (f *file) GetProjectPath() (string, error) {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 10:35 下午 2021/4/26
func (f *file) ReadYmlContent(filePath string, result interface{}) error {
func (f *file) ReadYmlContent(filePath string, result any) error {
if nil == result {
return errors.New("接收读取结果的数据指针为NIL")
}
@ -86,7 +86,7 @@ func (f *file) ReadYmlContent(filePath string, result interface{}) error {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:23 2022/6/9
func (f *file) ReadJSONContent(filePath string, result interface{}) error {
func (f *file) ReadJSONContent(filePath string, result any) error {
if nil == result {
return errors.New("接收读取结果的数据指针为NIL")
}
@ -105,7 +105,7 @@ func (f *file) ReadJSONContent(filePath string, result interface{}) error {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 13:21 2022/7/2
func (f *file) ReadIniContent(filePath string, result interface{}) error {
func (f *file) ReadIniContent(filePath string, result any) error {
if nil == result {
return errors.New("接收读取结果的数据指针为NIL")
}
@ -117,7 +117,7 @@ func (f *file) ReadIniContent(filePath string, result interface{}) error {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 21:08 2023/7/31
func (f *file) ReadTomlContent(filePath string, result interface{}) error {
func (f *file) ReadTomlContent(filePath string, result any) error {
if nil == result {
return errors.New("接收读取结果的数据指针为NIL")
}
@ -132,9 +132,9 @@ func (f *file) ReadTomlContent(filePath string, result interface{}) error {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 13:11 2022/7/2
func (f *file) ReadAnyFileContent(filePath string, receiver interface{}) error {
func (f *file) ReadAnyFileContent(filePath string, receiver any) error {
var (
parseFunc func(filePath string, receiver interface{}) error
parseFunc func(filePath string, receiver any) error
)
filePathArr := strings.Split(filePath, "#@#")
fileExt := ""