1 Star 2 Fork 3

kristas/booting-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
reader.go 602 Bytes
一键复制 编辑 原始数据 按行查看 历史
package config_reader
import (
"encoding/json"
"gopkg.in/yaml.v3"
"io/ioutil"
)
func ReadYAML(path string, config interface{}) {
file, err := ioutil.ReadFile(path)
if err != nil {
panic("Config error: " + err.Error())
}
err = yaml.Unmarshal(file, config)
if err != nil {
panic("Parse config to yaml failed: " + err.Error())
}
}
func ReadJSON(path string, config interface{}) {
file, err := ioutil.ReadFile(path)
if err != nil {
panic("Config error: " + err.Error())
}
err = json.Unmarshal(file, config)
if err != nil {
panic("Parse config to json failed: " + err.Error())
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kristas/booting-go.git
git@gitee.com:kristas/booting-go.git
kristas
booting-go
booting-go
v1.1.9

搜索帮助