增加toml文件读取
This commit is contained in:
parent
d9fac952a8
commit
e92246d281
17
file.go
17
file.go
@ -14,6 +14,8 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/util/define"
|
||||
|
||||
"github.com/go-ini/ini"
|
||||
@ -99,6 +101,21 @@ func (f *file) ReadIniContent(filePath string, result interface{}) error {
|
||||
return ini.MapTo(result, filePath)
|
||||
}
|
||||
|
||||
// ReadTomlContent 读取toml格式文件
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 21:08 2023/7/31
|
||||
func (f *file) ReadTomlContent(filePath string, result interface{}) error {
|
||||
if nil == result {
|
||||
return errors.New("接收读取结果的数据指针为NIL")
|
||||
}
|
||||
if _, err := toml.DecodeFile("example.toml", result); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadAnyFileContent 读取任意类型的文件并解析
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
|
1
go.mod
1
go.mod
@ -18,6 +18,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -1,3 +1,5 @@
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=
|
||||
github.com/Jeffail/gabs v1.4.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc=
|
||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
|
||||
|
Loading…
Reference in New Issue
Block a user